The patch titled Subject: checkpatch: add a --strict test for structs with bool member definitions has been added to the -mm tree. Its filename is checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Joe Perches <joe@xxxxxxxxxxx> Subject: 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/95477c93db187bab6da8a8ba7c57836868446179.camel@xxxxxxxxxxx Signed-off-by: Joe Perches <joe@xxxxxxxxxxx> Suggested-by: Peter Zijlstra <peterz@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff -puN scripts/checkpatch.pl~checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions scripts/checkpatch.pl --- a/scripts/checkpatch.pl~checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions +++ a/scripts/checkpatch.pl @@ -6257,6 +6257,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", _ Patches currently in -mm which might be from joe@xxxxxxxxxxx are checkpatch-improve-parse_email-signature-checking.patch checkpatch-improve-get_quoted_string-for-trace_event-macros.patch checkpatch-test-symbolic_perms-multiple-times-per-line.patch checkpatch-add-test-for-assignment-at-start-of-line.patch checkpatch-whinge-about-bool-bitfields.patch checkpatch-add-a-strict-test-for-structs-with-bool-member-definitions.patch maintainers-update-bouncing-aacraid-adapteccom-addresses.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html