mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-14 18:36:34 +00:00
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: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
5629411279
commit
6ad724e2a4
1 changed files with 2 additions and 2 deletions
|
|
@ -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 {/;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue