From: Mark Wielaard Date: Thu, 14 Nov 2024 11:25:27 +0000 (+0100) Subject: coregrind/m_gdbserver/remote-utils.c (prepare_resume_reply): Use memcpy X-Git-Tag: VALGRIND_3_25_0~238 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d7db69fbf482149e18ed1977df41fe320f5cbef2;p=thirdparty%2Fvalgrind.git 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. --- 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 ();