Patchwork checkpatch: Fix bracing false positives on #else

login
register
mail settings
Submitter Jan Kiszka
Date Jan. 21, 2011, 5:19 p.m.
Message ID <4D39C02C.80805@siemens.com>
Download mbox | patch
Permalink /patch/79873/
State New
Headers show

Comments

Jan Kiszka - Jan. 21, 2011, 5:19 p.m.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
---
 scripts/checkpatch.pl |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
Blue Swirl - Jan. 21, 2011, 5:35 p.m.
Thanks, applied.

On Fri, Jan 21, 2011 at 5:19 PM, Jan Kiszka <jan.kiszka@siemens.com> wrote:
> Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
> ---
>  scripts/checkpatch.pl |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 55ef439..4fa06c0 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2536,7 +2536,8 @@ sub process {
>                        }
>                }
>                if (!defined $suppress_ifbraces{$linenr - 1} &&
> -                                       $line =~ /\b(if|while|for|else)\b/) {
> +                                       $line =~ /\b(if|while|for|else)\b/ &&
> +                                       $line !~ /\#\s*else/) {
>                        my $allowed = 0;
>
>                        # Check the pre-context.
> --
> 1.7.1
>

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 55ef439..4fa06c0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2536,7 +2536,8 @@  sub process {
 			}
 		}
 		if (!defined $suppress_ifbraces{$linenr - 1} &&
-					$line =~ /\b(if|while|for|else)\b/) {
+					$line =~ /\b(if|while|for|else)\b/ &&
+					$line !~ /\#\s*else/) {
 			my $allowed = 0;
 
 			# Check the pre-context.