Detect suspicious indentation after conditional
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v2 Latest3 patches 0 repliesNew
- v13 patches 3 repliesSuperseded
Changelog from the cover letter
v2: Expanded fix to ctx_block_get, some minor simplifications
Patches in v2 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | checkpatch: Fix preprocessor guard handling in context tracker functionsscripts/ | +7 | 0 replies | |
| 2/3 | Suspicious indentation detection after conditional statementscripts/ | +41 | 0 replies | |
| 3/3 | checkpatch: Ignore labels when checking indentationscripts/ | +8 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.
Cover letter [PATCH v2 0/3] Detect suspicious indentation after conditional
This patch series is adding functionality to checkpatch.pl to test for incorrect code indentation after a conditional statement, like this:
if (a)
b;
c;
(Indentation implies that c; was guarded by the conditional, but it isn't.) The main part is re-sending a patch from Ivo Sieben that was already proposed in 2014 [1]. I don't know why it was never merged -- it seems that there was no discussion on it. I hope that it was only overlooked, because it works great, and I think this is a very important class of common error to catch.
I have tested it extensively on the kernel tree and in the course of that found a few more edge cases that get fixed by the other two patches. With all these applied, the vast majority of hits I get from this check on the kernel tree are actual indentation errors or other code style violations (e.g. case label and statement on the same line). The only significant remaining group of false positives I found are cases of macros being defined within a function, which are overall very rare. I think the benefit of adding this check would far outweigh the remaining amount of noise.
[1]: https://lore.kernel.org/patchwork/patch/465116
Ivo Sieben (1):
Suspicious indentation detection after conditional statement
Julius Werner (2):
checkpatch: ctx_statement_block: Fix preprocessor guard tracking
checkpatch: Ignore labels when checking indentation
Changelog:
v2: Expanded fix to ctx_block_get, some minor simplifications
scripts/checkpatch.pl | 56 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-)
Signature · 1 line
2.29.2