qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 8/8] migration: use pstrcpy to copy run state


From: Alex Bennée
Subject: [PATCH v1 8/8] migration: use pstrcpy to copy run state
Date: Thu, 3 Sep 2020 12:21:07 +0100

The gcov build triggered:

  ../../migration/global_state.c:47:5: error: ‘strncpy’ specified
      bound 100 equals destination size [-Werror=stringop-truncation]
      strncpy((char *)global_state.runstate

As we shouldn't be using strncpy anyway lets use the suggested
pstrcpy.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 migration/global_state.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/migration/global_state.c b/migration/global_state.c
index 25311479a4b..5fbe6d1ff07 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -44,8 +44,8 @@ void global_state_store_running(void)
 {
     const char *state = RunState_str(RUN_STATE_RUNNING);
     assert(strlen(state) < sizeof(global_state.runstate));
-    strncpy((char *)global_state.runstate,
-           state, sizeof(global_state.runstate));
+    pstrcpy((char *)global_state.runstate, sizeof(global_state.runstate),
+            state);
 }
 
 bool global_state_received(void)
-- 
2.20.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]