Re: Question about style when converting from K&R to ANSI C.

From: Linus Torvalds (
Date: Sun Jun 01 2003 - 21:09:17 EST

In article <>,
Larry McVoy <> wrote:
>On Sat, May 31, 2003 at 11:56:16PM -0600, Steven Cole wrote:
>> Proposed conversion:
>> int foo(void)
>> {
>> /* body here */
>> }
>Sometimes it is nice to be able to see function names with a
> grep '^[a-zA-Z].*(' *.c
>which is why I've always preferred
> /* body here */

That makes no sense.

Do you write your normal variable definitions like


too? No you don't, because that would be totally idiotic.

A function declaration is no different. The type of the function is very
important to the function itself (along with the arguments), and I
personally want to see _all_ of it when I grep for functions.

You should just do

        grep -i '^[a-z_ ]*(' *.c

and you'll get a nice function declaration with the standard kernel
coding style.

And I personally don't normally do "grep for random function
declarations", that just sounds like a contrieved example. I grep for
specific function names to find usage, and then it's _doubly_ important
to see that the return (and argument) types match and make sense.

So I definitely prefer all the arguments on the same line too, even if
that makes the line be closer to 100 chars than 80. The zlib K&R->ANSI
conversion was a special case, and I'd be happy if somebody were to have
the energy to convert it all the way (which implies moving comments
around etc).

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Sat Jun 07 2003 - 22:00:15 EST