diff options
author | Michal Zylowski <michal.zylowski@intel.com> | 2018-08-10 13:26:49 +1000 |
---|---|---|
committer | Stephen Rothwell <sfr@canb.auug.org.au> | 2018-08-13 04:12:08 +1000 |
commit | eb52730882f02485b634c9025fa7cb7a904c7ab9 (patch) | |
tree | cf36758644bf150a3ad74b25cdc176eb758133a0 /scripts | |
parent | 7dd9fd28e1de15df41f864e6ed08c25aea81ba0d (diff) | |
download | linux-next-eb52730882f02485b634c9025fa7cb7a904c7ab9.tar.gz |
checkpatch: check for space after "else" keyword
Current checkpatch implementation permits notation like
} else{
in kernel code. It looks like oversight and inconsistency in checkpatch
rules (e.g. instruction like 'do' is tested).
Add regex for checking space after 'else' keyword and trigger error if
space is not present.
Link: http://lkml.kernel.org/r/1533545753-8870-1-git-send-email-michal.zylowski@intel.com
Signed-off-by: Michal Zylowski <michal.zylowski@intel.com>
Acked-by: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/checkpatch.pl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index ce72cc4784e6..35c86c9b67f3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4531,11 +4531,11 @@ sub process { #need space before brace following if, while, etc if (($line =~ /\(.*\)\{/ && $line !~ /\($Type\)\{/) || - $line =~ /do\{/) { + $line =~ /\b(?:else|do)\{/) { if (ERROR("SPACING", "space required before the open brace '{'\n" . $herecurr) && $fix) { - $fixed[$fixlinenr] =~ s/^(\+.*(?:do|\)))\{/$1 {/; + $fixed[$fixlinenr] =~ s/^(\+.*(?:do|else|\)))\{/$1 {/; } } |