public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Joe Perches <joe@perches.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Miller <davem@davemloft.net>,
	netdev@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] checkpatch: Add --strict preference for #defines using BIT(foo)
Date: Sun, 9 Nov 2014 10:50:25 +0100	[thread overview]
Message-ID: <20141109095025.GA1840@nanopsycho.orion> (raw)
In-Reply-To: <1415394939.23530.20.camel@perches.com>

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;
>
>

  reply	other threads:[~2014-11-09  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1415265610-9338-1-git-send-email-jiri@resnulli.us>
     [not found] ` <1415265610-9338-10-git-send-email-jiri@resnulli.us>
     [not found]   ` <20141107.151607.480474516800359791.davem@davemloft.net>
2014-11-07 21:15     ` [PATCH] checkpatch: Add --strict preference for #defines using BIT(foo) Joe Perches
2014-11-09  9:50       ` Jiri Pirko [this message]
2014-11-09 14:22         ` Joe Perches
2014-11-10 23:36       ` Andrew Morton
2014-11-10 23:53         ` Joe Perches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20141109095025.GA1840@nanopsycho.orion \
    --to=jiri@resnulli.us \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox