checkpatch: Warn about data_race() without comment
authorMarco Elver <elver@google.com>
Wed, 1 Apr 2020 10:17:14 +0000 (12:17 +0200)
committerPaul E. McKenney <paulmck@kernel.org>
Wed, 6 May 2020 17:54:58 +0000 (10:54 -0700)
Warn about applications of data_race() without a comment, to encourage
documenting the reasoning behind why it was deemed safe.

Suggested-by: Will Deacon <will@kernel.org>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
scripts/checkpatch.pl

index a63380c6b0d20f8f2fd9c73b715343177f607bb7..48bb9508e3009ea9306b5843d6fcf9a57510fef0 100755 (executable)
@@ -5833,6 +5833,14 @@ sub process {
                        }
                }
 
+# check for data_race without a comment.
+               if ($line =~ /\bdata_race\s*\(/) {
+                       if (!ctx_has_comment($first_line, $linenr)) {
+                               WARN("DATA_RACE",
+                                    "data_race without comment\n" . $herecurr);
+                       }
+               }
+
 # check for smp_read_barrier_depends and read_barrier_depends
                if (!$file && $line =~ /\b(smp_|)read_barrier_depends\s*\(/) {
                        WARN("READ_BARRIER_DEPENDS",