[PATCH 3/3] sys_ident: Quiet strncpy warning

0 views
Skip to first unread message

Tyrel Datwyler

<tyreld@linux.ibm.com>
unread,
Aug 28, 2025, 4:12:27 PM (10 days ago) Aug 28
to powerpc-utils-devel@googlegroups.com, Michal Suchanek
From: Michal Suchanek <msuc...@suse.de>

The string is terminated by explicit NUL assignement below, use memcpy
instead of strncpy.

Signed-off-by: Michal Suchanek <msuc...@suse.de>
---
src/sys_ident.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sys_ident.c b/src/sys_ident.c
index 2c5c06b494b9..0d88a2db315f 100644
--- a/src/sys_ident.c
+++ b/src/sys_ident.c
@@ -364,7 +364,7 @@ print_sys_part_id(void)
temp[2] = '\0';
prefix = atoi(temp);

- strncpy(cc, sys_id+6, 2);
+ memcpy(cc, sys_id+6, 2);
cc[2] = '\0';

strncpy(sssss, sys_id+8, 5);
@@ -386,7 +386,7 @@ print_sys_part_id(void)

close(fd);

- strncpy(tttt, model+4, 4);
+ memcpy(tttt, model+4, 4);
tttt[4] = '\0';

fd = open("/proc/device-tree/ibm,partition-no", O_RDONLY);
--
2.51.0

Reply all
Reply to author
Forward
0 new messages