On Tue, 10 Apr 2018 11:19:54 -0700 Joe Perches <j...@perches.com> wrote:

> 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.

What's wrong with bools in structs?  The changelog should be
self-contained, please.  At least add a link in the changelog (of the
lkml.kernel.org/r/MSGID variety), but a link in the changelog is risky
because the reader may be offline or the server may be down.

> --- a/scripts/checkpatch.pl
> +++ b/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);

And... the server is down.  Am unable to understand or review this patch!

> +             }
> +
>  # check for semaphores initialized locked
>               if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
>                       WARN("CONSIDER_COMPLETION",

Reply via email to