Skip to content

Commit

Permalink
checkpatch: fix regressions in "fix handling of leading spaces"
Browse files Browse the repository at this point in the history
The patch "checkpatch: fix handling of leading spaces" added checks for
leading spaces on lines, but this introduces regressions.  Firstly it does
not correctly detect when we are in a comment.  Secondly it does not allow
for preprocessor command spacing.  Finally it does not allow for label
indentation which is required to be less than one tab.  Fix these up:

Signed-off-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Andy Whitcroft authored and Linus Torvalds committed Oct 26, 2010
1 parent 658716d commit 6b4c5be
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1459,10 +1459,13 @@ sub process {
}

# check for spaces at the beginning of a line.
if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) {
# Exceptions:
# 1) within comments
# 2) indented preprocessor commands
# 3) hanging labels
if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) {
my $herevet = "$here\n" . cat_vet($rawline) . "\n";
WARN("please, no space for starting a line, \
excluding comments\n" . $herevet);
WARN("please, no spaces at the start of a line\n" . $herevet);
}

# check we are in a valid C source file if not then ignore this hunk
Expand Down

0 comments on commit 6b4c5be

Please sign in to comment.