lkml.org 
[lkml]   [2018]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v2 1/2] jump_label: Explicitly disable jump labels in __init code

* Ingo Molnar <mingo@kernel.org> wrote:

> 2) code robustness
>
> For example:
>
> for (i = 0; i < 10; i++)
> if (foo)
> bar(i);
> baz(i);
>
> Is probably buggy code, although technically it's valid syntax and will compile
> just fine.
>
> If all multi-line statements have curly braces then this type of bug cannot occur:
>
> for (i = 0; i < 10; i++) {
> if (foo)
> bar(i);
> baz(i);
> }

Note that newer versions of GCC will warn about this pattern:

warning: this ‘for’ clause does not guard
this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’

But the warning is pretty restrictive and GCC won't warn about slightly more
complex patterns like:

for (i = 0; i < 10; i++)
if (foo)
bar(i);
// debug_fn();
baz(i);

Thanks,

Ingo

\
 
 \ /
  Last update: 2018-02-18 14:16    [W:1.190 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site