checkpatch: notice unbalanced else braces in a patch

Patches that add or modify code like

	} else
		<foo>
or
	else {
		<bar>

where one branch appears to have a brace and the other branch does not
have a brace should emit a --strict style message.

Link: http://lkml.kernel.org/r/c6be32747fc725cbc235802991746700a0f54fdc.1486754390.git.joe@perches.com
Signed-off-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:
Joe Perches 2017-02-24 15:01:41 -08:00 коммит произвёл Linus Torvalds
Родитель 1bde561e47
Коммит e4c5babd32
1 изменённых файлов: 6 добавлений и 0 удалений

Просмотреть файл

@ -5104,6 +5104,12 @@ sub process {
}
}
# check for single line unbalanced braces
if ($sline =~ /.\s*\}\s*else\s*$/ ||
$sline =~ /.\s*else\s*\{\s*$/) {
CHK("BRACES", "Unbalanced braces around else statement\n" . $herecurr);
}
# check for unnecessary blank lines around braces
if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
if (CHK("BRACES",