From: Joe Perches Date: Wed, 10 Dec 2014 23:51:57 +0000 (-0800) Subject: checkpatch: add --strict preference for #defines using BIT(foo) X-Git-Url: http://git.cdn.openwrt.org/?a=commitdiff_plain;h=0ab9019184f1de09409434204cb8fbffe8286e00;p=openwrt%2Fstaging%2Fblogic.git checkpatch: add --strict preference for #defines using BIT(foo) Using BIT(foo) and BIT_ULL(bar) is more common now. Suggest using these macros over #defines with 1< Cc: David Miller Cc: Jiri Pirko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 518cc2e58439..d06b6be2841e 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;