* checkpatch: brackets around single statements fix
@ 2012-05-02 15:10 Joe Korty
2012-05-02 15:32 ` Andy Whitcroft
0 siblings, 1 reply; 3+ messages in thread
From: Joe Korty @ 2012-05-02 15:10 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: joe.korty, linux-kernel
Checkpatch thinks '#else' is the same as 'else' in its check for
this error:
WARNING: braces {} are not necessary for single statement blocks
Signed-off-by: Joe Korty <joe.korty@ccur.com>
Index: linux/scripts/checkpatch.pl
===================================================================
--- linux.orig/scripts/checkpatch.pl 2012-04-17 05:00:37.000000000 -0400
+++ linux/scripts/checkpatch.pl 2012-05-02 10:29:03.000000000 -0400
@@ -3038,7 +3038,7 @@
}
}
if (!defined $suppress_ifbraces{$linenr - 1} &&
- $line =~ /\b(if|while|for|else)\b/) {
+ $line =~ /[^#]\b(if|while|for|else)\b/) {
my $allowed = 0;
# Check the pre-context.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: checkpatch: brackets around single statements fix
2012-05-02 15:10 checkpatch: brackets around single statements fix Joe Korty
@ 2012-05-02 15:32 ` Andy Whitcroft
2012-05-02 15:56 ` Joe Korty
0 siblings, 1 reply; 3+ messages in thread
From: Andy Whitcroft @ 2012-05-02 15:32 UTC (permalink / raw)
To: Joe Korty; +Cc: linux-kernel
On Wed, May 02, 2012 at 11:10:46AM -0400, Joe Korty wrote:
> Checkpatch thinks '#else' is the same as 'else' in its check for
> this error:
>
> WARNING: braces {} are not necessary for single statement blocks
>
> Signed-off-by: Joe Korty <joe.korty@ccur.com>
>
> Index: linux/scripts/checkpatch.pl
> ===================================================================
> --- linux.orig/scripts/checkpatch.pl 2012-04-17 05:00:37.000000000 -0400
> +++ linux/scripts/checkpatch.pl 2012-05-02 10:29:03.000000000 -0400
> @@ -3038,7 +3038,7 @@
> }
> }
> if (!defined $suppress_ifbraces{$linenr - 1} &&
> - $line =~ /\b(if|while|for|else)\b/) {
> + $line =~ /[^#]\b(if|while|for|else)\b/) {
> my $allowed = 0;
>
> # Check the pre-context.
Interesting. Got an example I can use to add to the test suite.
-apw
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: checkpatch: brackets around single statements fix
2012-05-02 15:32 ` Andy Whitcroft
@ 2012-05-02 15:56 ` Joe Korty
0 siblings, 0 replies; 3+ messages in thread
From: Joe Korty @ 2012-05-02 15:56 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: linux-kernel
On Wed, May 02, 2012 at 11:32:12AM -0400, Andy Whitcroft wrote:
> On Wed, May 02, 2012 at 11:10:46AM -0400, Joe Korty wrote:
> Interesting. Got an example I can use to add to the test suite.
Test case for scripts/checkpatch.pl: thinks '#else'
is the same as 'else', prints an error for brackets
around single statements.
Signed-off-by: Joe Korty <joe.korty@ccur.com>
--- /tmp/y.c 2012-05-02 11:53:28.000000000 -0400
+++ /tmp/x.c 2012-05-02 11:52:28.000000000 -0400
@@ -1,6 +1,10 @@
struct abc abc = {
{ a, "a " },
{ b, "b " },
+#ifdef CONFIG_REPURPOSE
+ { d, "d " },
+#else
{ c, "c " },
+#endif
{ },
};
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-05-02 15:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02 15:10 checkpatch: brackets around single statements fix Joe Korty
2012-05-02 15:32 ` Andy Whitcroft
2012-05-02 15:56 ` Joe Korty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®