Skip to content

Commit 021158b

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: add types for other OS typedefs
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". Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b671fde commit 021158b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

scripts/checkpatch.pl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,11 @@ sub hash_show_words {
339339
| $NON_ASCII_UTF8
340340
}x;
341341

342+
our $typeOtherOSTypedefs = qr{(?x:
343+
u_(?:char|short|int|long) | # bsd
344+
u(?:nchar|short|int|long) # sysv
345+
)};
346+
342347
our $typeTypedefs = qr{(?x:
343348
(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
344349
atomic_t
@@ -475,6 +480,7 @@ sub build_types {
475480
(?:$Modifier\s+|const\s+)*
476481
(?:
477482
(?:typeof|__typeof__)\s*\([^\)]*\)|
483+
(?:$typeOtherOSTypedefs\b)|
478484
(?:$typeTypedefs\b)|
479485
(?:${all}\b)
480486
)
@@ -492,6 +498,7 @@ sub build_types {
492498
(?:
493499
(?:typeof|__typeof__)\s*\([^\)]*\)|
494500
(?:$typeTypedefs\b)|
501+
(?:$typeOtherOSTypedefs\b)|
495502
(?:${allWithAttr}\b)
496503
)
497504
(?:\s+$Modifier|\s+const)*
@@ -3159,6 +3166,7 @@ sub process {
31593166
$line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ &&
31603167
$line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ &&
31613168
$line !~ /\b$typeTypedefs\b/ &&
3169+
$line !~ /\b$typeOtherOSTypedefs\b/ &&
31623170
$line !~ /\b__bitwise(?:__|)\b/) {
31633171
WARN("NEW_TYPEDEFS",
31643172
"do not add new typedefs\n" . $herecurr);

0 commit comments

Comments
 (0)