Coding standards. (Was: Re: [PATCH] [2.5] Non-blocking write can

Timothy Miller (miller@techsource.com)
Wed, 04 Jun 2003 11:21:41 -0400


Christoph Hellwig wrote:
> On Wed, Jun 04, 2003 at 01:58:02AM +0100, P. Benie wrote:
>
>>- if (down_interruptible(&tty->atomic_write)) {
>>- return -ERESTARTSYS;
>>+ if (file->f_flags & O_NONBLOCK) {
>>+ if (down_trylock(&tty->atomic_write))
>>+ return -EAGAIN;
>>+ }
>>+ else {
>
>
> The else should be on the same line as the closing brace, else
> the patch looks fine.

I am in general agreement with those who feel we should have a common
standard for code formatting. There are particular places where it's
VERY important to maximize consistency and readability, such as function
headers.

But when do standards turn into nitpicks?

I personally always write else as you suggest, "} else {", but the way
the other fellow did it does not in any way hurt readability for me.
Yes, it does irritate me sometimes when people put the braces and else
on three different lines, but mostly because it reduces the amount of
code I can see at one time. But even then, it doesn't make it any less
readable to me.

I can see patches getting rejected because they violate function header
standards. That would make sense to me. But if the above patch were to
be rejected on the basis of the "else", I would be hard pressed to see
that as a valid justification.

Perhaps it would be good to have an explanation for the relative
importance of placing braces and else on the same line as compared to
other formatting standards.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/