lkml.org 
[lkml]   [2007]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: coding style for long conditions
Date
On Friday 06 April 2007 2:38 pm, Roland Dreier wrote:
> [I can't believe I'm stepping into an indentation flamewar, but here goes...]

At least you weren't the target of attacks there ... for daring to
actually follow the only published Linux style guide in that area!!


> > Please change your coding style to conform to Documentation/CodingStyle.
> >
> > *** Only indent with tabs!! ***

Having a style guide is supposed to mean, among other things, that
following it gives you "safe harbor". Sigh.


> If you have a git tree handy, you can do "git show 68380b58" and see
> that Linus himself wrote:
>
> if (get_wq_data(work) == cwq
> && work_pending(work)
> && !list_empty(&work->entry)) {

Yeah, well even the chief penguin wrangler has occasionally
admitted to human imperfections. Not exclusively related to
the 0.99 kernel series, either ... ;)


> I have to admit that I would have put the &&s at the ends of the
> previous lines rather than where Linus put them,

I approve in particular of that location: beginning of line, where
they aren't masking the intent of the condition from a casual scan.
If there's a "right" place, that's it.

In particular, if you see lots of "&&" or "||" neatly lined up it
helps you understand something about when the conditional's body
will execute without needing to read to the end of every line.


> but... egads! Linus
> put spaces before the &&s to line them up nicely!
>
> "more in the breach" and all that I guess...

Yeah, nobody likes style nazis. On the other hand, it's rather
unusual to be the target of style nazism for actually following
the style guide!! You'd think that maybe the folk objecting to
that style guide might maybe choose a more direct way to address
their particular frustrations, eh? :)

- Dave


-
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/

\
 
 \ /
  Last update: 2007-04-07 00:09    [W:0.377 / U:0.108 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site