* [OT] Style Issues / Concerns
@ 2010-03-22 20:02 James Kosin
2010-03-22 20:13 ` Andi Kleen
0 siblings, 1 reply; 4+ messages in thread
From: James Kosin @ 2010-03-22 20:02 UTC (permalink / raw)
To: linux-kernel
Everyone,
1) Please forgive me if this is the wrong forum to post this.
2) Please CC me when replying... I'm having list issues right now.
3) Questions / Concerns:
I'm a bit confused as to why there has been a style push to remove
braces {} from the code.
Long ago, code was often missing these braces for exactly the point many
patches are now coming back and reverting back to this antiquated style.
The problem was, and the reason the style changed to include these
braces, was to prevent the common problem of forgetting the braces when
adding another statement to the if or else block of the code.
Example:
if( (x != 0) )
flag = true;
else
flag = false;
----
if( (x != 0) )
flag = true;
call_something();
else
flag = false;
----
Before everyone jumps in at once, this is a simple example that will
produce a compiler error about the misplaced else. However if there are
many if statements above this that may allow the else to be paired up
with it then the code will compile and there will be a serious and very
difficult bug in the code that will take days or months to find.
Why has the style for this changed back?
Does the compiler produce smaller code without the braces {}?
Just my 2-cents,
James Kosin
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [OT] Style Issues / Concerns
2010-03-22 20:02 [OT] Style Issues / Concerns James Kosin
@ 2010-03-22 20:13 ` Andi Kleen
2010-03-22 20:33 ` James Kosin
0 siblings, 1 reply; 4+ messages in thread
From: Andi Kleen @ 2010-03-22 20:13 UTC (permalink / raw)
To: James Kosin; +Cc: linux-kernel
James Kosin <jkosin@intcomgrp.com> writes:
>
> Before everyone jumps in at once, this is a simple example that will
> produce a compiler error about the misplaced else. However if there are
> many if statements above this that may allow the else to be paired up
> with it then the code will compile and there will be a serious and very
> difficult bug in the code that will take days or months to find.
Modern editors with auto indent mode makes it actually very easy
to find such bugs.
Also checkpatch.pl checks for it now I believe.
> Does the compiler produce smaller code without the braces {}?
No, it's very arbitary.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [OT] Style Issues / Concerns
2010-03-22 20:13 ` Andi Kleen
@ 2010-03-22 20:33 ` James Kosin
2010-03-22 20:55 ` Andi Kleen
0 siblings, 1 reply; 4+ messages in thread
From: James Kosin @ 2010-03-22 20:33 UTC (permalink / raw)
To: Andi Kleen; +Cc: linux-kernel
On 3/22/2010 4:13 PM, Andi Kleen wrote:
> James Kosin <jkosin@intcomgrp.com> writes:
>
>> Before everyone jumps in at once, this is a simple example that will
>> produce a compiler error about the misplaced else. However if there are
>> many if statements above this that may allow the else to be paired up
>> with it then the code will compile and there will be a serious and very
>> difficult bug in the code that will take days or months to find.
>>
> Modern editors with auto indent mode makes it actually very easy
> to find such bugs.
>
> Also checkpatch.pl checks for it now I believe.
>
Thanks for the speedy reply.
Does this mean developers need to install X or some graphical
environment now to develop the kernel?
If so what options are available to those that don't want a graphical
environment to develop under?
Sorry if I'm old fashioned.
Thanks again,
James K.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [OT] Style Issues / Concerns
2010-03-22 20:33 ` James Kosin
@ 2010-03-22 20:55 ` Andi Kleen
0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2010-03-22 20:55 UTC (permalink / raw)
To: James Kosin; +Cc: Andi Kleen, linux-kernel
On Mon, Mar 22, 2010 at 04:33:55PM -0400, James Kosin wrote:
> On 3/22/2010 4:13 PM, Andi Kleen wrote:
> > James Kosin <jkosin@intcomgrp.com> writes:
> >
> >> Before everyone jumps in at once, this is a simple example that will
> >> produce a compiler error about the misplaced else. However if there are
> >> many if statements above this that may allow the else to be paired up
> >> with it then the code will compile and there will be a serious and very
> >> difficult bug in the code that will take days or months to find.
> >>
> > Modern editors with auto indent mode makes it actually very easy
> > to find such bugs.
> >
> > Also checkpatch.pl checks for it now I believe.
> >
> Thanks for the speedy reply.
>
> Does this mean developers need to install X or some graphical
> environment now to develop the kernel?
Modern was perhaps the wrong word. emacs, vim support that.
-Andi
--
ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-22 20:55 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-22 20:02 [OT] Style Issues / Concerns James Kosin
2010-03-22 20:13 ` Andi Kleen
2010-03-22 20:33 ` James Kosin
2010-03-22 20:55 ` Andi Kleen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox