Re: [PATCH -mm] constify sched.c stat_nam strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, Jun 14, 2006 at 01:22:31AM +0400, Michael Tokarev wrote:
> Andreas Mohr wrote:
> > Hi all,
> > 
> > Signed-off-by: Andreas Mohr <[email protected]>
> > 
> > 
> > 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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux