Skip to contentSkip to conversation

checkpatch: Prefer strscpy to strlcpy

PATCH Applied Joe Perches 1 participant 1 message Dec 23, 2020 1 message not in the archive Checkpatch

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Joe Perches

author maintainer
#1 lore raw

PATCH 1/1 checkpatch: Prefer strscpy to strlcpy

Prefer strscpy over the deprecated strlcpy function.

---
 scripts/checkpatch.pl | 6 ++++++
 1 file changed, 6 insertions(+)
scripts/checkpatch.pl +6 -0
index 00085308ed9d..27679cc0ec17 100755
@@ -6646,6 +6646,12 @@ sub process {
 #			}
 #		}
 
+# strlcpy uses that should likely be strscpy
+		if ($line =~ /\bstrlcpy\s*\(/) {
+			WARN("STRLCPY",
+			     "Prefer strscpy over strlcpy - see: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw\@mail.gmail.com/\n" . $herecurr);
+		}
+
 # typecasts on min/max could be min_t/max_t
 		if ($perl_version_ok &&
 		    defined $stat &&