bsd and sysv use different typedefs for unsigned types. These are in types.h but not in checkpatch, so add them to checkpatch's ability to know types. This can avoid false positives for code like: void foo(void) { int x; uint y; [...]; } where checkpatch incorrectly emits a warning for "missing a blank line after declarations".
Showing the changes to scripts/checkpatch.pl (1 of 1 file). Show all
Unified · Split
| @@ -339,6 +339,11 @@ our $UTF8 = qr{ · 338 unmodified lines | ||
| 339 | 339 | | $NON_ASCII_UTF8 |
| 340 | 340 | }x; |
| 341 | 341 | |
| 342 | +our $typeOtherOSTypedefs = qr{(?x: | |
| 343 | + u_(?:char|short|int|long) | # bsd | |
| 344 | + u(?:nchar|short|int|long) # sysv | |
| 345 | +)}; | |
| 346 | + | |
| 342 | 347 | our $typeTypedefs = qr{(?x: |
| 343 | 348 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| |
| 344 | 349 | atomic_t |
| @@ -475,6 +480,7 @@ sub build_types { · 130 unmodified lines | ||
| 475 | 480 | (?:$Modifier\s+|const\s+)* |
| 476 | 481 | (?: |
| 477 | 482 | (?:typeof|__typeof__)\s*\([^\)]*\)| |
| 483 | + (?:$typeOtherOSTypedefs\b)| | |
| 478 | 484 | (?:$typeTypedefs\b)| |
| 479 | 485 | (?:${all}\b) |
| 480 | 486 | ) |
| @@ -492,6 +498,7 @@ sub build_types { · 11 unmodified lines | ||
| 492 | 498 | (?: |
| 493 | 499 | (?:typeof|__typeof__)\s*\([^\)]*\)| |
| 494 | 500 | (?:$typeTypedefs\b)| |
| 501 | + (?:$typeOtherOSTypedefs\b)| | |
| 495 | 502 | (?:${allWithAttr}\b) |
| 496 | 503 | ) |
| 497 | 504 | (?:\s+$Modifier|\s+const)* |
| @@ -3159,6 +3166,7 @@ sub process { · 2661 unmodified lines | ||
| 3159 | 3166 | $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && |
| 3160 | 3167 | $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && |
| 3161 | 3168 | $line !~ /\b$typeTypedefs\b/ && |
| 3169 | + $line !~ /\b$typeOtherOSTypedefs\b/ && | |
| 3162 | 3170 | $line !~ /\b__bitwise(?:__|)\b/) { |
| 3163 | 3171 | WARN("NEW_TYPEDEFS", |
| 3164 | 3172 | "do not add new typedefs\n" . $herecurr); |