mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
To: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com,
	borntraeger@linux.ibm.com, svens@linux.ibm.com,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	kevinpaul468@gmail.com
Cc: skhan@linuxfoundation.org
Subject: [PATCH] Removing deprecated strncpy()
Date: Thu, 10 Apr 2025 17:02:30 +0530	[thread overview]
Message-ID: <20250410113230.28116-1-kevinpaul468@gmail.com> (raw)

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

Signed-off-by: Kevin Paul Reddy Janagari <kevinpaul468@gmail.com>
---
 arch/s390/boot/printk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/boot/printk.c b/arch/s390/boot/printk.c
index 8cf6331bc060..8f3b2244ef1b 100644
--- a/arch/s390/boot/printk.c
+++ b/arch/s390/boot/printk.c
@@ -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");
-- 
2.39.5


             reply	other threads:[~2025-04-10 11:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-10 11:32 Kevin Paul Reddy Janagari [this message]
2025-04-10 11:54 ` Heiko Carstens
2025-04-10 12:32 Kevin Paul Reddy Janagari
2025-04-11  1:10 ` Tung Quang Nguyen
2025-04-11  5:06 Kevin Paul Reddy Janagari
2025-04-11  5:22 ` Tung Quang Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250410113230.28116-1-kevinpaul468@gmail.com \
    --to=kevinpaul468@gmail.com \
    --cc=agordeev@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=svens@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®