Skip to content

Commit 9a4cad4

Browse files
Eric Nelsontorvalds
authored andcommitted
checkpatch: check for whitespace before semicolon at EOL
Requires --strict option during invocation: ~/linux$ scripts/checkpatch --strict foo.patch This tests for a bad habits of mine like this: return 0 ; Note that it does allow a special case of a bare semicolon for empty loops: while (foo()) ; Signed-off-by: Eric Nelson <eric.nelson@boundarydevices.com> Cc: Andy Whitcroft <apw@canonical.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 133fd9f commit 9a4cad4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

scripts/checkpatch.pl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,13 @@ sub process {
24482448
"space prohibited between function name and open parenthesis '('\n" . $herecurr);
24492449
}
24502450
}
2451+
2452+
# check for whitespace before a non-naked semicolon
2453+
if ($line =~ /^\+.*\S\s+;/) {
2454+
CHK("SPACING",
2455+
"space prohibited before semicolon\n" . $herecurr);
2456+
}
2457+
24512458
# Check operator spacing.
24522459
if (!($line=~/\#\s*include/)) {
24532460
my $ops = qr{

0 commit comments

Comments
 (0)