From d7db69fbf482149e18ed1977df41fe320f5cbef2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Thu, 14 Nov 2024 12:25:27 +0100 Subject: [PATCH] coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy GCC8 (but apparently not later versions) complain about the use of strncpy when not actually copying a string: remote-utils.c:1140:14: warning: 'char* strncpy(char*, const char*, size_t)' output truncated before terminating nul copying 6 bytes from a string of the same length [-Wstringop-truncation] strncpy (buf, "watch:", 6); ~~~~~~~~^~~~~~~~~~~~~~~~~~ This is "harmless" because buf is large enough and we will add more chars (including a zero terminator) later. But using strncpy here is a bit odd because we don't really want to copy a string, but an array of 6 chars. So use memcpy here to do so, simplyfing the code. --- coregrind/m_gdbserver/remote-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coregrind/m_gdbserver/remote-utils.c b/coregrind/m_gdbserver/remote-utils.c index b22dc4482..8dfc768d4 100644 --- a/coregrind/m_gdbserver/remote-utils.c +++ b/coregrind/m_gdbserver/remote-utils.c @@ -1137,7 +1137,7 @@ void prepare_resume_reply (char *buf, char status, unsigned char sig) CORE_ADDR addr; int i; - strncpy (buf, "watch:", 6); + VG_(memcpy) (buf, "watch:", 6); buf += 6; addr = valgrind_stopped_data_address (); -- 2.11.4.GIT