Skip to contentSkip to conversation

checkpatch: warn about direct use of send_sig_info and force_sig_info

PATCH New Marco Elver 1 participant 1 message May 7, 2021 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 checkpatch: warn about direct use of send_sig_info and force_sig_info

Setting up siginfo and using send_sig_info() and force_sig_info() directly is discouraged. Instead, new code wanting to generate signals should use the appropriate helper specific to the signal.

Eric mentioned that he'd like to make these static at some point, but until that can happen, let's try to avoid introducing new users of them.

---
v3:
* Reword warning message (Joe Perches).
* Simplify regex (Joe Perches).

v2:
* Use ?: because we don't need $2 (suggested by Dwaipayan Ray).

v1: https://lkml.kernel.org/r/[email protected]

---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index ccb412a74725..c714543818e5 100755
@@ -7153,6 +7153,12 @@ sub process {
 			     "Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr);
 		}
 
+# check for direct use of send_sig_info(), force_sig_info()
+		if ($sline =~ /\b(force_sig_info|send_sig_info)\s*\(/) {
+			WARN("USE_SIGINFO_HELPER",
+			     "Prefer signal-specific helpers over use of '$1' (see: include/linux/sched/signal.h)\n" . $herecurr);
+		}
+
 # check for deprecated apis
 		if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
 			my $deprecated_api = $1;
Signature · 1 line
2.31.1.607.g51e8a6a459-goog