Messages in this thread | | | From | Justin Stitt <> | Date | Thu, 11 Apr 2024 15:10:57 -0700 | Subject | Re: [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?
>
| |