Removing deprecated strncpy()
PATCH 1/1 Removing deprecated strncpy()
This patch suggests the replacement of strncpy with strscpy as per the Documentation/process/deprecated
the strncpy() fails to guarntee NULL termination since the function adds zero pads, this isn't really convenient for short strings as it may cause performce issues
strscpy() is a preffered replacement because
it overcomes the limitations of strncpy as mentioned above
--- arch/s390/boot/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/boot/printk.c +1 -1
@@ -158,7 +158,7 @@ static noinline char *strsym(char *buf, void *ip) p =findsym ((unsigned long )ip, &off, &len);if (p) { -strncpy (buf, p,MAX_SYMLEN ); +strscpy (buf, p,MAX_SYMLEN );/* reserve 15 bytes for offset/len in symbol+0x1234/0x1234 */ p = buf +strnlen (buf,MAX_SYMLEN -15 );strcpy (p,"+0x" );
Signature · 1 line
2.39.5
Heiko Carstens
maintainerQuoted 19 lines · Kevin Paul Reddy Janagari
This patch suggests the replacement of strncpy with strscpy as per the
Documentation/process/deprecated
thestrncpy()fails to guarntee NULL termination since the function adds zero pads, this isn't really convenient for short strings as it may cause performce issues
strscpy()is a preffered replacement because
it overcomes the limitations of strncpy as mentioned aboveSigned-off-by Kevin Paul Reddy Janagari <[email protected]>--- arch/s390/boot/printk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/boot/printk.c +0
-0
arch/s390/boot/printk.c static noinline char *strsym(char *buf, void *ip) · line 161
Quoted 5 lines
arch/s390/boot/printk.c +1
-1@@ -158,7 +158,7 @@ static noinline char *strsym(char *buf, void *ip) p =findsym ((unsigned long )ip, &off, &len);if (p) { -strncpy (buf, p,MAX_SYMLEN ); +strscpy (buf, p,MAX_SYMLEN );
This won't even compile. Please compile test before sending any patches.