Warn about applications of context_unsafe() without a comment, to
encourage documenting the reasoning behind why it was deemed safe.

Signed-off-by: Marco Elver <[email protected]>
---
v4:
* Rename capability -> context analysis.
* Avoid nested if.
---
 scripts/checkpatch.pl | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c0250244cf7a..c4fd8bdff528 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6733,6 +6733,13 @@ sub process {
                        }
                }
 
+# check for context_unsafe without a comment.
+               if ($line =~ /\bcontext_unsafe\b/ &&
+                   !ctx_has_comment($first_line, $linenr)) {
+                       WARN("CONTEXT_UNSAFE",
+                            "context_unsafe without comment\n" . $herecurr);
+               }
+
 # check of hardware specific defines
                if ($line =~ 
m@^.\s*\#\s*if.*\b(__i386__|__powerpc64__|__sun__|__s390x__)\b@ && $realfile !~ 
m@include/asm-@) {
                        CHK("ARCH_DEFINES",
-- 
2.52.0.322.g1dd061c0dc-goog


Reply via email to