Skip to content

Commit

Permalink
checkpatch: check for whitespace before semicolon at EOL
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eric Nelson authored and Linus Torvalds committed Jun 1, 2012
1 parent 133fd9f commit 9a4cad4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2448,6 +2448,13 @@ sub process {
"space prohibited between function name and open parenthesis '('\n" . $herecurr);
}
}

# check for whitespace before a non-naked semicolon
if ($line =~ /^\+.*\S\s+;/) {
CHK("SPACING",
"space prohibited before semicolon\n" . $herecurr);
}

# Check operator spacing.
if (!($line=~/\#\s*include/)) {
my $ops = qr{
Expand Down

0 comments on commit 9a4cad4

Please sign in to comment.