From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Andy Whitcroft <apw@shadowen.org>
Cc: linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>,
Davidlohr Bueso <dave@stgolabs.net>
Subject: [PATCH] checkpatch: Whine about ACCESS_ONCE
Date: Sat, 16 Apr 2016 12:04:13 -0700 [thread overview]
Message-ID: <1460833453.19090.79.camel@perches.com> (raw)
In-Reply-To: <1460828078-5224-1-git-send-email-dave@stgolabs.net>
Add a test for use of ACCESS_ONCE that could be written using
READ_ONCE or WRITE_ONCE.
--fix it too if desired.
Signed-off-by: Joe Perches <joe@perches.com>
---
scripts/checkpatch.pl | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3d9c34..5e5d2a4 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -5837,6 +5837,28 @@ sub process {
}
}
+# whine about ACCESS_ONCE
+ if ($^V && $^V ge 5.10.0 &&
+ $line =~ /\bACCESS_ONCE\s*$balanced_parens\s*(=(?!=))?\s*($FuncArg)?/) {
+ my $par = $1;
+ my $eq = $2;
+ my $fun = $3;
+ $par =~ s/^\(\s*(.*)\s*\)$/$1/;
+ if (defined($eq)) {
+ if (WARN("PREFER_WRITE_ONCE",
+ "Prefer WRITE_ONCE(<FOO>, <BAR>) over ACCESS_ONCE(<FOO>) = <BAR>\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)\s*$eq\s*\Q$fun\E/WRITE_ONCE($par, $fun)/;
+ }
+ } else {
+ if (WARN("PREFER_READ_ONCE",
+ "Prefer READ_ONCE(<FOO>) over ACCESS_ONCE(<FOO>)\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/\bACCESS_ONCE\s*\(\s*\Q$par\E\s*\)/READ_ONCE($par)/;
+ }
+ }
+ }
+
# check for lockdep_set_novalidate_class
if ($line =~ /^.\s*lockdep_set_novalidate_class\s*\(/ ||
$line =~ /__lockdep_no_validate__\s*\)/ ) {
next prev parent reply other threads:[~2016-04-16 19:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-16 17:34 [PATCH -next] kernel: Replace ACCESS_ONCE with READ/WRITE_ONCE Davidlohr Bueso
2016-04-16 19:04 ` Joe Perches [this message]
2016-04-16 19:48 ` [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches
2016-04-17 5:43 ` Julia Lawall
2016-04-17 8:27 ` Joe Perches
2016-04-17 11:17 ` Julia Lawall
2016-04-17 11:39 ` Julia Lawall
2016-04-17 16:02 ` Joe Perches
[not found] ` <alpine.DEB.2.02.1604171944500.2004@localhost6.localdomain6>
[not found] ` <1460915801.19090.100.camel@perches.com>
[not found] ` <alpine.DEB.2.02.1604172001410.2004@localhost6.localdomain6>
2016-04-19 19:12 ` [Cocci] coccinelle: bool if (foo) return true; else return false; Joe Perches
2016-04-19 19:12 ` Joe Perches
2016-04-19 19:15 ` [Cocci] " Julia Lawall
2016-04-19 19:15 ` Julia Lawall
2016-04-20 7:19 ` [Cocci] " Michael Stefaniuc
2016-04-20 7:19 ` Michael Stefaniuc
2016-04-20 7:25 ` Joe Perches
2016-04-20 7:25 ` Joe Perches
2016-04-17 17:26 ` [PATCH V2] checkpatch: Whine about ACCESS_ONCE 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=1460833453.19090.79.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@shadowen.org \
--cc=dave@stgolabs.net \
--cc=dbueso@suse.de \
--cc=linux-kernel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.