Messages in this thread | | | Subject | Re: [PATCH v2] checkpatch: warn about direct use of send_sig_info and force_sig_info | From | Joe Perches <> | Date | Thu, 06 May 2021 14:41:31 -0700 |
| |
On Thu, 2021-05-06 at 17:22 +0200, Marco Elver wrote: > Setting up siginfo and using send_sig_info() or 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. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -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 ($line =~ /\b((?:force|send)_sig_info)\(/) {
You want to be able to find uses like 'force_sig_info (<foo>...' so you should add a \s* after the capture group. And it's probably simpler and more readable to use if ($sline =~ /\b(force_sig_info|send_sig_info)\s*\(/) { instead of the more complex regex
(sline is stripped of comments, $line is not)
> + WARN("USE_SIGINFO_HELPER", > + "Where possible, avoid using '$1' directly and use a signal-specific helper setting required siginfo fields (see include/linux/sched/signal.h).\n" . $herecurr);
A rather long and complex sentence. How about "Prefer signal-specific helpers over use of '$1' (see: include/linux/sched/signal.h)\n"
And in that signal.h file, there's no obvious reference to these signal-specific helpers. Is there a better reference in the Documentation/ tree?
| |