diff options
author | Joe Perches <[email protected]> | 2018-08-21 21:57:26 -0700 |
---|---|---|
committer | Linus Torvalds <[email protected]> | 2018-08-22 10:52:48 -0700 |
commit | d729593e492e1e4c7cd8a418ee227d0bd4d5f36d (patch) | |
tree | 364ee3dd079163719b1e75a0914517ecfc83cbc2 | |
parent | de9df3993cfffde468c1c226382f24cec7e9fedc (diff) |
checkpatch: add a --strict test for structs with bool member definitions
A struct with a bool member can have different sizes on various
architectures because neither bool size nor alignment is standardized.
So emit a message on the use of bool in structs only in .h files and not
.c files.
There is the real possibility that this test could have a false positive
when a bool is declared as an automatic, so limit the test to .h files
where the only false positive is for declarations in static inline
functions.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Joe Perches <[email protected]>
Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
-rwxr-xr-x | scripts/checkpatch.pl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 447857ffaf6b..5cb7cfd08ce2 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6251,6 +6251,13 @@ sub process { "Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr); } +# check for bool use in .h files + if ($realfile =~ /\.h$/ && + $sline =~ /^.\s+bool\s*$Ident\s*(?::\s*d+\s*)?;/) { + CHK("BOOL_MEMBER", + "Avoid using bool structure members because of possible alignment issues - see: https://lkml.org/lkml/2017/11/21/384\n" . $herecurr); + } + # check for semaphores initialized locked if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { WARN("CONSIDER_COMPLETION", |