Skip to content

Commit 3e49a19

Browse files
cfriedtkartben
authored andcommitted
scripts: checkpatch: add special consideration for DIR
DIR is a POSIX type defined via the dirent.h header. In Zephyr, we define it as `typedef void DIR`, since it is only ever described via a pointer (much like `FILE`). However, in checkpatch.pl, functions that return DIR* or accept a DIR* argument are met with an error of the form below: ``` ERROR:SPACING: need consistent spacing around '*' (ctx:WxV) ``` Examples that trigger this false positive are, for example ```cpp int dirfd(DIR *dirp); DIR *fdopendir(int fd); ``` Include `DIR` as a class of specific POSIX types that should be matched as types rather than other tokens. Signed-off-by: Chris Friedt <[email protected]>
1 parent fa841fe commit 3e49a19

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

scripts/checkpatch.pl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,10 +464,13 @@ sub hash_show_words {
464464
(?:__)?(?:u|s|be|le)(?:8|16|32|64)|
465465
atomic_t
466466
)};
467+
# DIR is misinterpreted as a macro or value in some POSIX headers
468+
our $typePosixTypedefs = qr{DIR};
467469
our $typeTypedefs = qr{(?x:
468470
$typeC99Typedefs\b|
469471
$typeOtherOSTypedefs\b|
470-
$typeKernelTypedefs\b
472+
$typeKernelTypedefs\b|
473+
$typePosixTypedefs\b
471474
)};
472475

473476
our $zero_initializer = qr{(?:(?:0[xX])?0+$Int_type?|NULL|false)\b};

0 commit comments

Comments
 (0)