On Mon, Sep 07, 2026 at 09:57:30AM -0700, Stephen Hemminger wrote:
> Add dpdk-checkpatch.py as a standalone alternative to checkpatches.sh.
> Unlike the existing shell script wrapper around checkpatch.pl, this
> requires no Linux kernel source tree or Perl installation and is
> significantly faster (~0.4s vs ~2m23s on a recent patch series).
>
> Supports the same usage patterns: patch files, mbox bundles, git commit
> ranges (-r), last N commits (-n), and stdin. Implements common style
> checks (spacing, line length, spelling via codespell) plus
> DPDK-specific forbidden token and tag checks.
>
> Signed-off-by: Stephen Hemminger <[email protected]>
> Acked-by: Bruce Richardson <[email protected]>
> ---
> v5 - revise to cover more and have less false positives
>
> devtools/dpdk-checkpatch.py | 2062 +++++++++++++++++++++++++++++++++++
> 1 file changed, 2062 insertions(+)
> create mode 100755 devtools/dpdk-checkpatch.py
>
<snip>
> +
> + # STRNCPY: should use strlcpy
> + if re.search(r"\bstrncpy\s*\(", content):
> + self.add_result(
> + "WARNING",
> + "STRNCPY",
> + "Prefer strlcpy over strncpy - see:
> https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=v6a6g1ouzcprm...@mail.gmail.com/",
That's not the link you want for that. While it does, in fairness, point out an
issue with strlcpy (which also applies to other fns like snprintf), strlcpy
is still far safer than strncpy, and currently the most widely available
safe replacement. I think a short message saying to use strlcpy over
strncpy is sufficient.
> + filename,
> + line_num,
> + content,
> + )
> +
> + # STRCPY: unsafe string copy
> + if re.search(r"\bstrcpy\s*\(", content):
> + self.add_result(
> + "ERROR",
> + "STRCPY",
> + "strcpy is unsafe - use strlcpy or snprintf",
Merge this check with above one, no need to check separately for strcpy and
strncpy when both have the same replacement. Also, no need to mention use
of snprintf in the message. Suggest join check with message:
"Use strlcpy over strcpy/strncpy"
> + filename,
> + line_num,
> + content,
> + )
> +
<snip>