lkml.org 
[lkml]   [2024]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v4] checkpatch: add check for snprintf to scnprintf
On Thu, Apr 11, 2024 at 1:56 PM Joe Perches <joe@perches.com> wrote:
> It could.
>
> # {v}snprintf uses that should likely be {v}scnprintf
> if ($line =~ /\b((v?)snprintf)\s*\(/) {
> WARN("SNPRINTF",
> "Prefer ${2}scnprintf over $1 - see: https://github.com/KSPP/linux/issues/105\n" . $herecurr);
> }
>
>
>
> Though I also think it's better to use lore rather than github

I am fine with making the UX change in v5 regarding using ${2} and $1
but I wish someone could have said something about the Github links
earlier, we already have a pattern going with these string api
changes:

"Prefer strscpy over strcpy - see:
https://github.com/KSPP/linux/issues/88\n" . $herecurr);
}

..
# strlcpy uses that should likely be strscpy
if ($line =~ /\bstrlcpy\s*\(/) {
WARN("STRLCPY",
"Prefer strscpy over strlcpy - see:
https://github.com/KSPP/linux/issues/89\n" . $herecurr);
}

# strncpy uses that should likely be strscpy or strscpy_pad
if ($line =~ /\bstrncpy\s*\(/) {
WARN("STRNCPY",
"Prefer strscpy, strscpy_pad, or __nonstring over strncpy - see:
https://github.com/KSPP/linux/issues/90\n" . $herecurr);
}

# {v}snprintf uses that should likely be {v}scnprintf
if ($line =~ /\b(v|)snprintf\s*\(/) {
WARN("SNPRINTF",
"Prefer ${2}scnprintf over $1 - see:
https://github.com/KSPP/linux/issues/105\n" . $herecurr);
..


It should be noted that nowhere else is a lore link or github link
provided during a warning, so there really is no precedence. Joe what
should we do?

>

\
 
 \ /
  Last update: 2024-05-27 16:36    [W:0.030 / U:1.204 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site