From: Andreas Mohr <andi@rhlx01.fht-esslingen.de>
To: Michael Tokarev <mjt@tls.msk.ru>
Cc: Andrew Morton <akpm@osdl.org>,
kernel list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH -mm] constify sched.c stat_nam strings
Date: Thu, 29 Jun 2006 21:43:20 +0200 [thread overview]
Message-ID: <20060629194320.GA11245@rhlx01.fht-esslingen.de> (raw)
In-Reply-To: <448F2C97.2090103@tls.msk.ru>
Hi,
On Wed, Jun 14, 2006 at 01:22:31AM +0400, Michael Tokarev wrote:
> Andreas Mohr wrote:
> > Hi all,
> >
> > Signed-off-by: Andreas Mohr <andi@lisas.de>
> >
> >
> > diff -urN linux-2.6.17-rc6-mm2.orig/kernel/sched.c linux-2.6.17-rc6-mm2.my/kernel/sched.c
> > --- linux-2.6.17-rc6-mm2.orig/kernel/sched.c 2006-06-13 19:28:17.000000000 +0200
> > +++ linux-2.6.17-rc6-mm2.my/kernel/sched.c 2006-06-13 19:32:03.000000000 +0200
> > @@ -4662,7 +4662,7 @@
> > task_t *relative;
> > unsigned state;
> > unsigned long free = 0;
> > - static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> > + static const char * const stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> >
> > printk("%-13.13s ", p->comm);
> > state = p->state ? __ffs(p->state) + 1 : 0;
>
> How about the following instead:
>
> --- kernel/sched.c.orig 2006-05-31 22:23:53.000000000 +0400
> +++ kernel/sched.c 2006-06-14 01:19:17.000000000 +0400
> @@ -5287,14 +5287,11 @@ static void show_task(task_t *p)
> task_t *relative;
> unsigned state;
> unsigned long free = 0;
> - static const char *stat_nam[] = { "R", "S", "D", "T", "t", "Z", "X" };
> + static const char stat_nam[] = "RSDTtZX";
>
> - printk("%-13.13s ", p->comm);
> state = p->state ? __ffs(p->state) + 1 : 0;
> - if (state < ARRAY_SIZE(stat_nam))
> - printk(stat_nam[state]);
> - else
> - printk("?");
> + printk("%-13.13s %c", p->comm,
> + state < sizeof(stat_nam) - 1 ? stat_nam[state] : '?');
> #if (BITS_PER_LONG == 32)
> printk(" %08lX ", (unsigned long)p);
> #else
>
> ?
Sounds nice, especially as it saves 124 Bytes compared to my version.
I'm planning to merge it into my sched.c cleanup with proper attribution.
Thanks!
Andreas Mohr
next prev parent reply other threads:[~2006-06-29 19:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-13 19:55 Andreas Mohr
2006-06-13 21:22 ` Michael Tokarev
2006-06-29 19:43 ` Andreas Mohr [this message]
2006-06-29 20:17 ` [PATCH -mm] small kernel/sched.c cleanup Andreas Mohr
2006-06-29 20:57 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060629194320.GA11245@rhlx01.fht-esslingen.de \
--to=andi@rhlx01.fht-esslingen.de \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mjt@tls.msk.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®