All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] migration: Replace strncpy() by g_strlcpy()
@ 2018-08-18  2:56 Philippe Mathieu-Daudé
  2018-08-20  9:57 ` Juan Quintela
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-08-18  2:56 UTC (permalink / raw)
  To: Juan Quintela, Dr. David Alan Gilbert, David Hildenbrand,
	Howard Spoelstra
  Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial

Fedora 29 comes with GCC 8.1 which added the 'stringop-truncation' checks.

Replace the strncpy() calls by g_strlcpy() to avoid the following warning:

  migration/global_state.c: In function 'global_state_store_running':
  migration/global_state.c:45:5: error: 'strncpy' specified bound 100 equals destination size [-Werror=stringop-truncation]
       strncpy((char *)global_state.runstate,
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              state, sizeof(global_state.runstate));
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reported-by: Howard Spoelstra <hsp.cat7@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
See http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg03723.html

 migration/global_state.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/global_state.c b/migration/global_state.c
index 8e8ab5c51e..d5df502cd5 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -42,7 +42,7 @@ int global_state_store(void)
 void global_state_store_running(void)
 {
     const char *state = RunState_str(RUN_STATE_RUNNING);
-    strncpy((char *)global_state.runstate,
+    g_strlcpy((char *)global_state.runstate,
            state, sizeof(global_state.runstate));
 }
 
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2018-08-21 11:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-18  2:56 [Qemu-devel] [PATCH] migration: Replace strncpy() by g_strlcpy() Philippe Mathieu-Daudé
2018-08-20  9:57 ` Juan Quintela
2018-08-20 12:42 ` David Hildenbrand
2018-08-20 13:23 ` Paolo Bonzini
2018-08-20 13:28   ` David Hildenbrand
2018-08-20 17:16     ` Thomas Huth
2018-08-20 19:48       ` Eric Blake
2018-08-20 19:59         ` David Hildenbrand
2018-08-21  6:03           ` Thomas Huth
2018-08-21  9:39             ` Paolo Bonzini
2018-08-21 11:52               ` Juan Quintela

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.