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-Tag: v3.19-rc1~135^2~73 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ab9019184f1de09409434204cb8fbffe8286e00;p=profile%2Fcommon%2Fplatform%2Fkernel%2Flinux-artik7.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 518cc2e..d06b6be 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;