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:
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -1459,10 +1459,13 @@ sub process { · 1458 unmodified lines | ||
| 1459 | 1459 | } |
| 1460 | 1460 | |
| 1461 | 1461 | # check for spaces at the beginning of a line. |
| 1462 | − if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) { | |
| 1462 | +# Exceptions: | |
| 1463 | +# 1) within comments | |
| 1464 | +# 2) indented preprocessor commands | |
| 1465 | +# 3) hanging labels | |
| 1466 | + if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) { | |
| 1463 | 1467 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; |
| 1464 | − WARN("please, no space for starting a line, \ | |
| 1465 | − excluding comments\n" . $herevet); | |
| 1468 | + WARN("please, no spaces at the start of a line\n" . $herevet); | |
| 1466 | 1469 | } |
| 1467 | 1470 | |
| 1468 | 1471 | # check we are in a valid C source file if not then ignore this hunk |