2006-12-07 08:48:06

by Randy Dunlap

[permalink] [raw]
Subject: [PATCH/RFC] CodingStyle updates

From: Randy Dunlap <[email protected]>

Add some kernel coding style comments, mostly pulled from emails
by Andrew Morton, Jesper Juhl, and Randy Dunlap.

- add paragraph on switch/case indentation
- add paragraph on multiple-assignments
- add more on Braces
- add section on Spaces
- add paragraph on function breaks in source files
- add paragraph on EXPORT_SYMBOL placement
- add section on /*-comment style, long-comment style, and data
declarations and comments
- correct some chapter number references that were missed when
chapters were renumbered

Signed-off-by: Randy Dunlap <[email protected]>
---
Documentation/CodingStyle | 107 +++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 102 insertions(+), 5 deletions(-)

--- linux-2.6.19-git7.orig/Documentation/CodingStyle
+++ linux-2.6.19-git7/Documentation/CodingStyle
@@ -35,12 +35,34 @@ In short, 8-char indents make things eas
benefit of warning you when you're nesting your functions too deep.
Heed that warning.

+The preferred way to ease multiple indentation levels in a switch
+statement is to align the "switch" and its subordinate "case" labels in
+the same column instead of "double-indenting" the "case" labels. E.g.:
+
+ switch (suffix) {
+ case 'G':
+ case 'g':
+ mem <<= 10;
+ case 'M':
+ case 'm':
+ mem << 10;
+ case 'K':
+ case 'k':
+ mem << 10;
+ default:
+ break;
+ }
+
+
Don't put multiple statements on a single line unless you have
something to hide:

if (condition) do_this;
do_something_everytime;

+Don't put multiple assignments on a single line either. Kernel
+coding style is super simple. Avoid tricky expressions.
+
Outside of comments, documentation and except in Kconfig, spaces are never
used for indentation, and the above example is deliberately broken.

@@ -69,7 +91,7 @@ void fun(int a, int b, int c)
next_statement;
}

- Chapter 3: Placing Braces
+ Chapter 3: Placing Braces and Spaces

The other issue that always comes up in C styling is the placement of
braces. Unlike the indent size, there are few technical reasons to
@@ -81,6 +103,20 @@ brace last on the line, and put the clos
we do y
}

+This applies to all non-function statement blocks (if, switch, for,
+while, do). E.g.:
+
+ switch (action) {
+ case KOBJ_ADD:
+ return "add";
+ case KOBJ_REMOVE:
+ return "remove";
+ case KOBJ_CHANGE:
+ return "change";
+ default:
+ return NULL;
+ }
+
However, there is one special case, namely functions: they have the
opening brace at the beginning of the next line, thus:

@@ -121,6 +157,40 @@ supply of new-lines on your screen is no
25-line terminal screens here), you have more empty lines to put
comments on.

+ 3.1: Spaces
+
+Linux kernel style for use of spaces depends (mostly) on
+function-versus-keyword usage. Use a space after (most) keywords.
+The notable exception is "sizeof", which looks like a function
+(and is usually used with parentheses in Linux, although they are
+not required in the language, as in: "sizeof struct file").
+So use a space after these keywords:
+ if, switch, case, for, do, while
+but not with "sizeof". E.g.,
+ s = sizeof(struct file);
+
+Do not add spaces around (inside) parenthesized expressions.
+This example is *bad*:
+
+ s = sizeof( struct file );
+
+When declaring pointer data or a function that returns a pointer type,
+the preferred use of '*' is adjacent to the data name or function name
+and not adjacent to the type name. Examples:
+
+ char *linux_banner;
+ unsigned long long memparse(char *ptr, char **retptr);
+ char *match_strdup(substring_t *s);
+
+Use one space around (on each side of) most binary operators, such as
+any of these:
+ = + - < > * / % | & ^ <= >= == !=
+
+but no space after unary operators:
+ sizeof ++ -- & * + - ~ ! defined
+
+and no space around the '.' unary operator.
+

Chapter 4: Naming

@@ -152,7 +222,7 @@ variable that is used to hold a temporar

If you are afraid to mix up your local variable names, you have another
problem, which is called the function-growth-hormone-imbalance syndrome.
-See next chapter.
+See chapter 6 (Functions).


Chapter 5: Typedefs
@@ -258,6 +328,16 @@ generally easily keep track of about 7 d
and it gets confused. You know you're brilliant, but maybe you'd like
to understand what you did 2 weeks from now.

+In source files, separate functions with one blank line.
+If the function is exported, the EXPORT* macro for it should follow
+immediately after the closing function brace line. E.g.:
+
+int system_is_up(void)
+{
+ return system_state == SYSTEM_RUNNING;
+}
+EXPORT_SYMBOL(system_is_up);
+

Chapter 7: Centralized exiting of functions

@@ -306,16 +386,33 @@ time to explain badly written code.
Generally, you want your comments to tell WHAT your code does, not HOW.
Also, try to avoid putting comments inside a function body: if the
function is so complex that you need to separately comment parts of it,
-you should probably go back to chapter 5 for a while. You can make
+you should probably go back to chapter 6 for a while. You can make
small comments to note or warn about something particularly clever (or
ugly), but try to avoid excess. Instead, put the comments at the head
of the function, telling people what it does, and possibly WHY it does
it.

-When commenting the kernel API functions, please use the kerneldoc format.
+When commenting the kernel API functions, please use the kernel-doc format.
See the files Documentation/kernel-doc-nano-HOWTO.txt and scripts/kernel-doc
for details.

+Linux style for comments is the pre-C99 "/* ... */" style.
+Don't use C99-style "// ..." comments.
+
+The preferred style for long (multi-line) comments is:
+
+ /*
+ * This is the preferred style for multi-line
+ * comments in the Linux kernel source code.
+ * Please use it consistently.
+ */
+
+It's also important to comment data, whether they are basic types or
+derived types. To this end, use just one data declaration per line
+(no commas for multiple data declarations). This leaves you room for
+a small comment on each item, explaining its use.
+
+
Chapter 9: You've made a mess of it

That's OK, we all do. You've probably been told by your long-time Unix
@@ -591,4 +688,4 @@ Kernel CodingStyle, by [email protected] at
http://www.kroah.com/linux/talks/ols_2002_kernel_codingstyle_talk/html/

--
-Last updated on 30 April 2006.
+Last updated on 2006-December-06.


---


2006-12-07 08:54:28

by Jesper Juhl

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On 07/12/06, Randy Dunlap <[email protected]> wrote:
> From: Randy Dunlap <[email protected]>
>
> Add some kernel coding style comments, mostly pulled from emails
> by Andrew Morton, Jesper Juhl, and Randy Dunlap.
>
> - add paragraph on switch/case indentation
> - add paragraph on multiple-assignments
> - add more on Braces
> - add section on Spaces
> - add paragraph on function breaks in source files
> - add paragraph on EXPORT_SYMBOL placement
> - add section on /*-comment style, long-comment style, and data
> declarations and comments
> - correct some chapter number references that were missed when
> chapters were renumbered
>
> Signed-off-by: Randy Dunlap <[email protected]>

Acked-by: Jesper Juhl <[email protected]>


--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2006-12-07 11:13:12

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates


On Dec 7 2006 00:48, Randy Dunlap wrote:
>+The preferred way to ease multiple indentation levels in a switch
>+statement is to align the "switch" and its subordinate "case" labels in
>+the same column instead of "double-indenting" the "case" labels. E.g.:
>+
>+ switch (suffix) {
>+ case 'G':
>+ case 'g':
>+ mem <<= 10;
>+ case 'M':
>+ case 'm':
>+ mem << 10;
^^^^^^^^^^

Statement has no effect ;-)

>+ case 'K':
>+ case 'k':
>+ mem << 10;

Make that <<=.

>+Use one space around (on each side of) most binary operators, such as
>+any of these:
>+ = + - < > * / % | & ^ <= >= == !=

And the ternary operator ?:

>+but no space after unary operators:
>+ sizeof ++ -- & * + - ~ ! defined

And no space before these unary operators,
++ (postincrement) -- (postdecrement)

What keyword is "defined"? Did you have too much Perl coffee? :)

>+and no space around the '.' unary operator.

Same goes for ->


>+Linux style for comments is the pre-C99 "/* ... */" style.

Aka C89.

>+Don't use C99-style "// ..." comments.
>+
>+The preferred style for long (multi-line) comments is:
>+
>+ /*
>+ * This is the preferred style for multi-line
>+ * comments in the Linux kernel source code.
>+ * Please use it consistently.
>+ */

Description: Stars to the left with two almost blank (/*, */) lines.



-`J'
--

2006-12-07 16:01:58

by Chris Friesen

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Jan Engelhardt wrote:

> What keyword is "defined"? Did you have too much Perl coffee? :)

Maybe macro formatting?

#if defined(CONFIG_FOO)

Chris

2006-12-07 23:15:00

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On Thu, 07 Dec 2006 15:06:35 -0800 (PST) David Miller wrote:

> From: Randy Dunlap <[email protected]>
> Date: Thu, 07 Dec 2006 15:00:31 -0800
>
> > Alistair John Strachan wrote:
> >
> > >> +but no space after unary operators:
> > >> + sizeof ++ -- & * + - ~ ! defined
> > >
> > > You could mention typeof too, which is a keyword but should be done like
> > > sizeof.
> >
> > Hm, is that a gcc-ism? It's not listed in the C99 spec.
> >
> > Are there other gcc-isms that I should add?
>
> Perhaps you should add typeof and alignof, for starters.

OK, I added both of those. Thanks.

Will resend soon.
---
~Randy

2006-12-07 18:30:35

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates


>> What keyword is "defined"? Did you have too much Perl coffee? :)
>
> Maybe macro formatting?
>
> #if defined(CONFIG_FOO)

Ah thanks for the hint. This also raises another stylistic aspect:

#ifdef XYZ over #if defined(XYZ) when there is only one macro to be
tested for.


-`J'
--

2006-12-07 21:36:45

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Jan Engelhardt wrote:
>>> What keyword is "defined"? Did you have too much Perl coffee? :)
>> Maybe macro formatting?
>>
>> #if defined(CONFIG_FOO)

Yes, that's it.

> Ah thanks for the hint. This also raises another stylistic aspect:
>
> #ifdef XYZ over #if defined(XYZ) when there is only one macro to be
> tested for.

I'm not sure that we care enough to put it into CodingStyle.

--
~Randy

2006-12-07 23:00:10

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Alistair John Strachan wrote:

>> +but no space after unary operators:
>> + sizeof ++ -- & * + - ~ ! defined
>
> You could mention typeof too, which is a keyword but should be done like
> sizeof.

Hm, is that a gcc-ism? It's not listed in the C99 spec.

Are there other gcc-isms that I should add?

Thanks.
--
~Randy

2006-12-07 22:54:41

by Alistair John Strachan

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Hi Randy,

On Thursday 07 December 2006 08:48, Randy Dunlap wrote:
[snip]
> + 3.1: Spaces
> +
> +Linux kernel style for use of spaces depends (mostly) on
> +function-versus-keyword usage. Use a space after (most) keywords.
> +The notable exception is "sizeof", which looks like a function
> +(and is usually used with parentheses in Linux, although they are
> +not required in the language, as in: "sizeof struct file").
> +So use a space after these keywords:
> + if, switch, case, for, do, while
> +but not with "sizeof". E.g.,
> + s = sizeof(struct file);
> +
> +Do not add spaces around (inside) parenthesized expressions.
> +This example is *bad*:
> +
> + s = sizeof( struct file );
> +
> +When declaring pointer data or a function that returns a pointer type,
> +the preferred use of '*' is adjacent to the data name or function name
> +and not adjacent to the type name. Examples:
> +
> + char *linux_banner;
> + unsigned long long memparse(char *ptr, char **retptr);
> + char *match_strdup(substring_t *s);
> +
> +Use one space around (on each side of) most binary operators, such as
> +any of these:
> + = + - < > * / % | & ^ <= >= == !=
> +
> +but no space after unary operators:
> + sizeof ++ -- & * + - ~ ! defined

You could mention typeof too, which is a keyword but should be done like
sizeof.

--
Cheers,
Alistair.

Final year Computer Science undergraduate.
1F2 55 South Clerk Street, Edinburgh, UK.

2006-12-07 23:06:33

by David Miller

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

From: Randy Dunlap <[email protected]>
Date: Thu, 07 Dec 2006 15:00:31 -0800

> Alistair John Strachan wrote:
>
> >> +but no space after unary operators:
> >> + sizeof ++ -- & * + - ~ ! defined
> >
> > You could mention typeof too, which is a keyword but should be done like
> > sizeof.
>
> Hm, is that a gcc-ism? It's not listed in the C99 spec.
>
> Are there other gcc-isms that I should add?

Perhaps you should add typeof and alignof, for starters.

2006-12-07 23:26:32

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates


On Dec 7 2006 15:00, Randy Dunlap wrote:
>
>> > +but no space after unary operators:
>> > + sizeof ++ -- & * + - ~ ! defined
>>
>> You could mention typeof too, which is a keyword but should be done like
>> sizeof.
>
> Hm, is that a gcc-ism? It's not listed in the C99 spec.
>
> Are there other gcc-isms that I should add?

__attribute__(()) perhaps, which is often seen in kernel code.



-fno-gnu-keywords
Do not recognize "typeof" as a keyword, so that code can use this
word as an identifier. You can use the keyword "__typeof__"
instead. -ansi implies -fno-gnu-keywords.

Ergo it's a GNUism/GCCism. As long as <whatever> is used in kernel code,
it should be documented.


-`J'
--

2006-12-07 21:36:47

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Jan Engelhardt wrote:
> On Dec 7 2006 00:48, Randy Dunlap wrote:
>> +The preferred way to ease multiple indentation levels in a switch
>> +statement is to align the "switch" and its subordinate "case" labels in
>> +the same column instead of "double-indenting" the "case" labels. E.g.:
>> +
>> + switch (suffix) {
>> + case 'G':
>> + case 'g':
>> + mem <<= 10;
>> + case 'M':
>> + case 'm':
>> + mem << 10;
> ^^^^^^^^^^
>
> Statement has no effect ;-)

Argh, thanks, fixed these.
And removed most fall-throughs to make it a better example.

>> +Use one space around (on each side of) most binary operators, such as
>> +any of these:
>> + = + - < > * / % | & ^ <= >= == !=
>
> And the ternary operator ?:

Added.

>> +but no space after unary operators:
>> + sizeof ++ -- & * + - ~ ! defined
>
> And no space before these unary operators,
> ++ (postincrement) -- (postdecrement)
>
> What keyword is "defined"? Did you have too much Perl coffee? :)
>
>> +and no space around the '.' unary operator.
>
> Same goes for ->

Added.

>> +Linux style for comments is the pre-C99 "/* ... */" style.
>
> Aka C89.

Changed.

>> +Don't use C99-style "// ..." comments.
>> +
>> +The preferred style for long (multi-line) comments is:
>> +
>> + /*
>> + * This is the preferred style for multi-line
>> + * comments in the Linux kernel source code.
>> + * Please use it consistently.
>> + */
>
> Description: Stars to the left with two almost blank (/*, */) lines.

Added.

Thanks. Will resend later today...

--
~Randy

2006-12-14 22:41:37

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

David Weinehall wrote:
> On Thu, Dec 07, 2006 at 12:48:38AM -0800, Randy Dunlap wrote:
>
> [snip]
>
>> +but no space after unary operators:
>> + sizeof ++ -- & * + - ~ ! defined
>
> Uhm, that doesn't compute... If you don't put a space after sizeof,
> the program won't compile.
>
> int c;
> printf("%d", sizeofc);

Uh, we prefer not to see "sizeof c". IOW, we prefer to have
the parentheses use all the time. Maybe I need to say that better?

> Options are:
>
> sizeof c
> sizeof(c)
>
> or
>
> sizeof (c)
>
> If you take sizeof the type rather than the variable, the options are
>
> sizeof(int)
>
> or
>
> sizeof (int)
>
> [snip]
>
>
> Regards: David Weinehall


--
~Randy

2006-12-14 22:59:38

by David Weinehall

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On Thu, Dec 07, 2006 at 12:48:38AM -0800, Randy Dunlap wrote:

[snip]

> +but no space after unary operators:
> + sizeof ++ -- & * + - ~ ! defined

Uhm, that doesn't compute... If you don't put a space after sizeof,
the program won't compile.

int c;
printf("%d", sizeofc);

Options are:

sizeof c
sizeof(c)

or

sizeof (c)

If you take sizeof the type rather than the variable, the options are

sizeof(int)

or

sizeof (int)

[snip]


Regards: David Weinehall
--
/) David Weinehall <[email protected]> /) Northern lights wander (\
// Maintainer of the v2.0 kernel // Dance across the winter sky //
\) http://www.acc.umu.se/~tao/ (/ Full colour fire (/

2006-12-14 23:33:10

by Scott Preece

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

> Outside of comments, documentation and except in Kconfig, spaces are never
> used for indentation, and the above example is deliberately broken.
---

I realize it isn't text you added, but what's that supposed to mean?
Surely the 8-character indents are made up of spaces. Does it mean
"spaces other than 8-space blocks"? In any case, how does it synch
with the following chapter's statement that continuations " are placed
substantially to the right" - isn't that done with spaces, too?

Or am I just totally spacing out on what was meant?

scott

2006-12-14 23:42:21

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

Scott Preece wrote:
[1]
>> Outside of comments, documentation and except in Kconfig, spaces are
>> never
>> used for indentation, and the above example is deliberately broken.
> ---
>
> I realize it isn't text you added, but what's that supposed to mean?
> Surely the 8-character indents are made up of spaces. Does it mean

No, the 8-character indents are made of one ASCII TAB character.

> "spaces other than 8-space blocks"? In any case, how does it synch
> with the following chapter's statement that continuations " are placed
> substantially to the right" - isn't that done with spaces, too?

That's usually (preferably) done with tab(s). Sometimes it is done
with a few spaces instead. (and we put up with it :)

> Or am I just totally spacing out on what was meant?

I take [1] to mean that this example:

if (condition) do_this;
do_something_everytime;

is broken in at least 3 ways:
1/ do_this(); should be on a separate line;
2/ do_something_everytime() should not be indented more than the "if"
above it; and
3/ *if* do_something_everytime() were to be indented more than it is,
it should be done with a tab, not spaces.

--
~Randy

2006-12-14 23:54:20

by Scott Preece

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On 12/14/06, Randy Dunlap <[email protected]> wrote:
> Scott Preece wrote:
> [1]
> >> Outside of comments, documentation and except in Kconfig, spaces are
> >> never
> >> used for indentation, and the above example is deliberately broken.
> > ---
> >
> > I realize it isn't text you added, but what's that supposed to mean?
> > Surely the 8-character indents are made up of spaces. Does it mean
>
> No, the 8-character indents are made of one ASCII TAB character.
----

Probably should say so, then. As it is, the only way to figure that
out (other than loking at code (:)) is to infer it from the .emacs
example, which doesn't come until 8 chapters later in the document.

Maybe:

Outside of comments, documentation, and Kconfig, use TAB characters
for indentation. Spaces are never used for indentation, and the above
example is deliberately broken in several ways, including use of
spaces.

scott

2006-12-15 00:11:27

by Robert P. J. Day

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On Thu, 14 Dec 2006, Randy Dunlap wrote:

> David Weinehall wrote:
> > On Thu, Dec 07, 2006 at 12:48:38AM -0800, Randy Dunlap wrote:
> >
> > [snip]
> >
> > > +but no space after unary operators:
> > > + sizeof ++ -- & * + - ~ ! defined
> >
> > Uhm, that doesn't compute... If you don't put a space after sizeof,
> > the program won't compile.
> >
> > int c;
> > printf("%d", sizeofc);
>
> Uh, we prefer not to see "sizeof c". IOW, we prefer to have the
> parentheses use all the time. Maybe I need to say that better?

here's a *really* rough first pass, i'm sure the end result would need
some hand tweaking:

=============================================
#!/bin/sh

DIR=$1

#
# Put in missing parentheses.
#

for f in $(grep -Erl "sizeof [^\(]" ${DIR}) ; do
echo $f
perl -pi -e "s/sizeof ([*]?[A-Za-z0-9_>\[\]\.-]+)( *)/sizeof\(\1\)\2/g" $f
done


#
# Delete possible space between "sizeof" and "(".
#

for f in $(grep -rl "sizeof (" ${DIR}) ; do
perl -pi -e "s/sizeof \(/sizeof\(/g" $f
done

#
# Delete obnoxious spaces inside parentheses.
#

for f in $(grep -rl "sizeof( " ${DIR}) ; do
perl -pi -e "s/sizeof\( *([^ \)]+) *\)/sizeof\(\1\)/g" $f
done
===========================================

rday

2006-12-15 00:25:38

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On Thu, 14 Dec 2006 19:07:27 -0500 (EST) Robert P. J. Day wrote:

> On Thu, 14 Dec 2006, Randy Dunlap wrote:
>
> > David Weinehall wrote:
> > > On Thu, Dec 07, 2006 at 12:48:38AM -0800, Randy Dunlap wrote:
> > >
> > > [snip]
> > >
> > > > +but no space after unary operators:
> > > > + sizeof ++ -- & * + - ~ ! defined
> > >
> > > Uhm, that doesn't compute... If you don't put a space after sizeof,
> > > the program won't compile.
> > >
> > > int c;
> > > printf("%d", sizeofc);
> >
> > Uh, we prefer not to see "sizeof c". IOW, we prefer to have the
> > parentheses use all the time. Maybe I need to say that better?
>
> here's a *really* rough first pass, i'm sure the end result would need
> some hand tweaking:

You can certainly send such (generated) patches to Andrew or other
subsystem maintainers if you'd like, but I'm more interested in
not adding more crud to the tree in the future.

IOW, sure, we prefer sizeof(foo) to sizeof foo, but the latter isn't
killing us. If someone is there making other changes, it would be
OK to change that also.

Compare: http://lkml.org/lkml/2006/12/7/191

---
~Randy

2006-12-15 00:49:01

by Robert P. J. Day

[permalink] [raw]
Subject: Re: [PATCH/RFC] CodingStyle updates

On Thu, 14 Dec 2006, Randy Dunlap wrote:

> On Thu, 14 Dec 2006 19:07:27 -0500 (EST) Robert P. J. Day wrote:
>
> > On Thu, 14 Dec 2006, Randy Dunlap wrote:
> >
> > > David Weinehall wrote:
> > > > On Thu, Dec 07, 2006 at 12:48:38AM -0800, Randy Dunlap wrote:
> > > >
> > > > [snip]
> > > >
> > > > > +but no space after unary operators:
> > > > > + sizeof ++ -- & * + - ~ ! defined
> > > >
> > > > Uhm, that doesn't compute... If you don't put a space after sizeof,
> > > > the program won't compile.
> > > >
> > > > int c;
> > > > printf("%d", sizeofc);
> > >
> > > Uh, we prefer not to see "sizeof c". IOW, we prefer to have the
> > > parentheses use all the time. Maybe I need to say that better?
> >
> > here's a *really* rough first pass, i'm sure the end result would need
> > some hand tweaking:
>
> You can certainly send such (generated) patches to Andrew or other
> subsystem maintainers if you'd like, but I'm more interested in not
> adding more crud to the tree in the future.
>
> IOW, sure, we prefer sizeof(foo) to sizeof foo, but the latter isn't
> killing us. If someone is there making other changes, it would be
> OK to change that also.

the advantage to standardizing what's there is that it makes it easier
to make subsequent changes. as a perfect example, because there are
several variations to the use of "sizeof", trying to catch every
combination that might be replaceable by the use of ARRAY_SIZE() is
just that much harder since you'd have to (as i had to) use regular
expressions to check for every variant -- parentheses or no
parentheses? space after the word or not? internal spaces within the
parentheses?

all that variation makes global changes for more useful stuff a real
pain.

rday