lkml.org 
[lkml]   [2014]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] checkpatch: Add --strict preference for #defines using BIT(foo)
Fri, Nov 07, 2014 at 10:15:39PM CET, joe@perches.com wrote:
>Using BIT(foo) and BIT_ULL(bar) is more common now.
>Suggest using these macros over #defines with 1<<value.

Joe, regarding the other Dave's comment, the multiline one, that is also
not covered by checkpatch. Would please you take care of that as well?

Thanks.

>
>Add a --fix option too.
>
>Signed-off-by: Joe Perches <joe@perches.com>
>---
> scripts/checkpatch.pl | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
>diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
>index 893cbd5..b5dc3f4 100755
>--- a/scripts/checkpatch.pl
>+++ b/scripts/checkpatch.pl
>@@ -4973,6 +4973,17 @@ sub process {
> }
> }
>
>+# check for #defines like: 1 << <digit> 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;
>
>


\
 
 \ /
  Last update: 2014-11-09 11:01    [W:0.157 / U:0.412 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site