qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] checkpatch.pl false positive: wants braces on #if


From: Blue Swirl
Subject: Re: [Qemu-devel] checkpatch.pl false positive: wants braces on #if
Date: Fri, 25 Feb 2011 17:38:45 +0200

On Wed, Feb 23, 2011 at 6:07 PM, Peter Maydell <address@hidden> wrote:
> If you run checkpatch.pl on this patch:
> http://patchwork.ozlabs.org/patch/84189/
>
> it complains:
> WARNING: braces {} are necessary even for single statement blocks
> #29: FILE: tcg/tcg.c:454:
> +#if defined(CONFIG_DEBUG_TCG)
> +    s->temps_in_use++;
>
>
> ...but braces on a cpp conditional are a bit tricky :-)
>
> The script is sufficiently hairy perl that I'm afraid I
> can't suggest a solution, only report the problem.

Maybe this helps:
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 075b614..4b1e2c2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2537,7 +2537,7 @@ sub process {
                }
                if (!defined $suppress_ifbraces{$linenr - 1} &&
                                        $line =~ /\b(if|while|for|else)\b/ &&
-                                       $line !~ /\#\s*else/) {
+                                       $line !~ /\#\s*(if|else|elif)/) {
                        my $allowed = 0;

                        # Check the pre-context.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]