diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 518cc2e58439c72b991b969aa6ecbe1c70391ec5..d06b6be2841e29c86e3510a262a594c993d5a674 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4975,6 +4975,17 @@ sub process { } } +# check for #defines like: 1 << that could be BIT(digit) + if ($line =~ /#\s*define\s+\w+\s+\(?\s*1\s*([ulUL]*)\s*\<\<\s*(?:\d+|$Ident)\s*\)?/) { + my $ull = ""; + $ull = "_ULL" if (defined($1) && $1 =~ /ll/i); + if (CHK("BIT_MACRO", + "Prefer using the BIT$ull macro\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\(?\s*1\s*[ulUL]*\s*<<\s*(\d+|$Ident)\s*\)?/BIT${ull}($1)/; + } + } + # check for case / default statements not preceded by break/fallthrough/switch if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { my $has_break = 0;