lkml.org 
[lkml]   [2007]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] bracing the loop in kernel/softirq.c
[Jeremy Fitzhardinge - Thu, Jun 21, 2007 at 11:52:25AM -0700]
> Jesper Juhl wrote:
>> On 20/06/07, Cyrill Gorcunov <gorcunov@gmail.com> wrote:
>>> This trivial patch adds braces over a one-line
>>> loop. That makes code...well... little bit
>>> convenient for (possible) further modifications.
>>>
>> That's generally not done.
>>
>> It's even in Documentation/CodingStyle :
>>
>> "
>> Do not unnecessarily use braces where a single statement will do.
>>
>> if (condition)
>> action();
>> "
>
> I tend to see "do {} while()" as an exception to this. I find the
> construct is sufficiently rare that it helps to emphasize it a bit. For
> example if I'm scanning code and I see:
>
> while (foo != NULL);
>
> in the corner of my eye, I'm going to think "huh?". But:
>
> } while (foo != NULL);
>
> visually "parses" properly, regardless of how near or far the corresponding
> "do {" is.
>
> (And of course, its consistent with the super extra special while-while
> loop:
>
> while (foo != NULL) {
> foo = bar();
> piffle();
> } while (foo != NULL); // make sure we loop properly
>
> ;)
>
> J
>

Indeed, 'do-while' is a special case.
Btw, Jeremy, I'm always getting into rapture on 'while-while' loop ;)

Cyrill

-
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-06-22 15:59    [W:0.059 / U:0.404 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site