Skip to contentSkip to conversation

Bug in checkpatch.pl?

Qemu-devel Pavel Borzenkov 2 participants 2 messages Aug 26, 2011

lore
Share & tools
lore
#0 lore raw

Hi.

checkpatch.pl correctly reports a warning for the following code:

if (something)

    foo;
else
    bar;

WARNING: braces {} are necessary for all arms of this statement #1: FILE: tmp/a.c:1:
+if (something)
[...]
+else
[...]

But if I modify it as follows, checkpatch.pl doesn't report any warning/error:

if (something) {
    foo;
} else
    bar;

Doesn't QEMU coding style forbid such constructions?

Signature · 1 line
Pavel
#1 lore raw
Quoted 18 lines · Pavel Borzenkov

checkpatch.pl correctly reports a warning for the following code:

if (something)
   foo;
else
   bar;

WARNING: braces {} are necessary for all arms of this statement #1: FILE: tmp/a.c:1:

(quoted diff) +2 -0
+if (something)
[...]
+else
[...]

But if I modify it as follows, checkpatch.pl doesn't report any warning/error:

Quoted 6 lines

if (something) {
   foo;
} else
   bar;

Doesn't QEMU coding style forbid such constructions?

Yes, it is forbidden. The only "exception" is:

if (something) {
    foo;
} else if (something_else) {
    bar;
}

Looks worth fixing to me.

Stefan