Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-17 Thread Robert P. J. Day
On Sun, 17 Dec 2006, Randy Dunlap wrote: > On Sun, 17 Dec 2006 13:13:59 -0500 (EST) Robert P. J. Day wrote: > > > > > so here's the end result of my experiment to replace unnecessary > > code snippets with an invocation of the ARRAY_SIZE() macro from > > include/linux/kernel.h. i've attached th

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-17 Thread Randy Dunlap
On Sun, 17 Dec 2006 13:13:59 -0500 (EST) Robert P. J. Day wrote: > > so here's the end result of my experiment to replace unnecessary > code snippets with an invocation of the ARRAY_SIZE() macro from > include/linux/kernel.h. i've attached the script that i ran on the > entire tree, then (afte

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-17 Thread Robert P. J. Day
so here's the end result of my experiment to replace unnecessary code snippets with an invocation of the ARRAY_SIZE() macro from include/linux/kernel.h. i've attached the script that i ran on the entire tree, then (after adding al viro's connector patch), did: $ make allyesconfig # for the

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-17 Thread Stefan Richter
Jan Engelhardt wrote: > On Dec 16 2006 08:09, Robert P. J. Day wrote: >> On Sat, 16 Dec 2006, Pavel Machek wrote: but we already have, from "include/linux/kernel.h": #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) >>> Hmmm. quite misleading name :-(. ARRAY_LEN would be better.

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Jan Engelhardt
On Dec 16 2006 08:09, Robert P. J. Day wrote: >On Sat, 16 Dec 2006, Pavel Machek wrote: >> > but we already have, from "include/linux/kernel.h": >> > >> > #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) >> >> Hmmm. quite misleading name :-(. ARRAY_LEN would be better. > >i suspect it's *way*

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Robert P. J. Day
(i'm not *trying* to belabour this issue ... i am merely succeeding) On Sat, 16 Dec 2006, Tim Schmielau wrote: > On Sat, 16 Dec 2006, Robert P. J. Day wrote: ... > > ... it's amazing the variation that you find beyond the obvious: > > > > $ grep -Er "sizeof.*/.*sizeof" . | less > > > > ... > > .

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Tim Schmielau
On Sat, 16 Dec 2006, Robert P. J. Day wrote: > On Fri, 15 Dec 2006, Tim Schmielau wrote: > > > > It might be interesting to grep for anything that divides two > > sizeofs and eyeball the result for possible mistakes. This would > > provide some real benefit beyond the cosmetical changes. > > i did

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Robert P. J. Day
On Sat, 16 Dec 2006, Pavel Machek wrote: > Hi! > > > there are numerous places throughout the source tree that apparently > > calculate the size of an array using the construct > > "sizeof(fubar)/sizeof(fubar[0])". see for yourself: > > > > $ grep -Er "sizeof\((.*)\) ?/ ?sizeof\(\1\[0\]\)" * >

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Robert P. J. Day
On Fri, 15 Dec 2006, Tim Schmielau wrote: > On Fri, 15 Dec 2006, Robert P. J. Day wrote: > > On Fri, 15 Dec 2006, Jan Engelhardt wrote: > > > Even sizeof a / sizeof *a > > > > > > may happen. > > > > yes, sadly, there are a number of those as well. back to the drawing > > board. > > It might be

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-16 Thread Pavel Machek
Hi! > there are numerous places throughout the source tree that apparently > calculate the size of an array using the construct > "sizeof(fubar)/sizeof(fubar[0])". see for yourself: > > $ grep -Er "sizeof\((.*)\) ?/ ?sizeof\(\1\[0\]\)" * > > but we already have, from "include/linux/kernel.h"

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-15 Thread Tim Schmielau
On Fri, 15 Dec 2006, Robert P. J. Day wrote: > On Fri, 15 Dec 2006, Jan Engelhardt wrote: > > Even sizeof a / sizeof *a > > > > may happen. > > yes, sadly, there are a number of those as well. back to the drawing > board. It might be interesting to grep for anything that divides two sizeofs and

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-15 Thread Robert P. J. Day
On Fri, 15 Dec 2006, Jan Engelhardt wrote: > > >>> Indeed, there seems to be lots of potential clean-up there. > >>> Including duplicate macros like: > >>> > >>> ./drivers/ide/ide-cd.h:#define ARY_LEN(a) ((sizeof(a) / sizeof(a[0]))) > >> > >> not surprisingly, i have a script "arraysize.sh": > >..

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-15 Thread Jan Engelhardt
>>> Indeed, there seems to be lots of potential clean-up there. >>> Including duplicate macros like: >>> >>> ./drivers/ide/ide-cd.h:#define ARY_LEN(a) ((sizeof(a) / sizeof(a[0]))) >> >> not surprisingly, i have a script "arraysize.sh": >... > >This could also come in the flavor "sizeof(a) / sizeo

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-14 Thread Robert P. J. Day
On Fri, 15 Dec 2006, Miguel Ojeda wrote: > On 12/13/06, Robert P. J. Day <[EMAIL PROTECTED]> wrote: > > > > there are numerous places throughout the source tree that apparently > > calculate the size of an array using the construct > > "sizeof(fubar)/sizeof(fubar[0])". see for yourself: > > > >

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-14 Thread Miguel Ojeda
On 12/13/06, Robert P. J. Day <[EMAIL PROTECTED]> wrote: there are numerous places throughout the source tree that apparently calculate the size of an array using the construct "sizeof(fubar)/sizeof(fubar[0])". see for yourself: $ grep -Er "sizeof\((.*)\) ?/ ?sizeof\(\1\[0\]\)" * but we al

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-14 Thread Stefan Richter
Robert P. J. Day wrote: > On Thu, 14 Dec 2006, Zach Brown wrote: ... >> Indeed, there seems to be lots of potential clean-up there. >> Including duplicate macros like: >> >> ./drivers/ide/ide-cd.h:#define ARY_LEN(a) ((sizeof(a) / sizeof(a[0]))) > > not surprisingly, i have a script "arraysize.sh":

Re: lots of code could be simplified by using ARRAY_SIZE()

2006-12-14 Thread Robert P. J. Day
On Thu, 14 Dec 2006, Zach Brown wrote: > > there are numerous places throughout the source tree that > > apparently calculate the size of an array using the construct > > "sizeof(fubar)/sizeof(fubar[0])". see for yourself: > > $ grep -Er "sizeof\((.*)\) ?/ ?sizeof\(\1\[0\]\)" * > > Indeed, ther

lots of code could be simplified by using ARRAY_SIZE()

2006-12-13 Thread Robert P. J. Day
there are numerous places throughout the source tree that apparently calculate the size of an array using the construct "sizeof(fubar)/sizeof(fubar[0])". see for yourself: $ grep -Er "sizeof\((.*)\) ?/ ?sizeof\(\1\[0\]\)" * but we already have, from "include/linux/kernel.h": #define ARRAY