Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1380588
| From | Joe Perches <joe@perches.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] checkpatch: Whine about ACCESS_ONCE |
| Date | 2016-04-16 21:10 +0200 |
| Message-ID | <roDLs-8sy-5@gated-at.bofh.it> (permalink) |
| References | <roCmn-7gH-33@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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*\)/ ) {
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -next] kernel: Replace ACCESS_ONCE with READ/WRITE_ONCE Davidlohr Bueso <dave@stgolabs.net> - 2016-04-16 19:40 +0200
[PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-16 21:10 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-16 21:50 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 07:50 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 10:30 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 13:20 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 13:40 +0200
Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 18:10 +0200
coccinelle: bool if (foo) return true; else return false; Joe Perches <joe@perches.com> - 2016-04-19 21:20 +0200
Re: coccinelle: bool if (foo) return true; else return false; Julia Lawall <julia.lawall@lip6.fr> - 2016-04-19 21:20 +0200
Re: [Cocci] coccinelle: bool if (foo) return true; else return false; Michael Stefaniuc <mstefani@redhat.com> - 2016-04-20 09:20 +0200
Re: [Cocci] coccinelle: bool if (foo) return true; else return false; Joe Perches <joe@perches.com> - 2016-04-20 09:30 +0200
[PATCH V2] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 19:30 +0200
csiph-web