lkml.org 
[lkml]   [2018]   [Apr]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH] checkpatch: whinge about bool bitfields
    From
    Date
    Using bool in a bitfield isn't a good idea as the
    alignment behavior is arch implementation defined.

    Suggest using unsigned int or u<8|16|32> instead.

    Signed-off-by: Joe Perches <joe@perches.com>
    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    ---
    scripts/checkpatch.pl | 6 ++++++
    1 file changed, 6 insertions(+)

    diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
    index eb534d48140e..e16d6713f236 100755
    --- a/scripts/checkpatch.pl
    +++ b/scripts/checkpatch.pl
    @@ -6251,6 +6251,12 @@ sub process {
    }
    }

    +# check for bool bitfields
    + if ($sline =~ /^.\s+bool\s*$Ident\s*:\s*\d+\s*;/) {
    + WARN("BOOL_BITFIELD",
    + "Avoid using bool as bitfield. Prefer bool bitfields as unsigned int or u<8|16|32>\n" . $herecurr);
    + }
    +
    # check for semaphores initialized locked
    if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
    WARN("CONSIDER_COMPLETION",
    \
     
     \ /
      Last update: 2018-04-10 17:42    [W:4.521 / U:0.092 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site