@samitouri / QOSamiQemu / commits / 22facc21ab

migration/global_state: replace strcpy("") with explicit NUL termination

Drop the unnecessary strcpy of an empty literal (and its spurious (char *)& cast) in favor of a direct NUL store, which avoids the libc call and hides no bugs behind a cast. Signed-off-by: Bin Guo <guobin@linux.alibaba.com> Reviewed-by: Fabiano Rosas <farosas@suse.de> Link: https://lore.kernel.org/r/20260518110112.21395-3-guobin@linux.alibaba.com Signed-off-by: Peter Xu <peterx@redhat.com>

Bin Guo committed May 18, 2026 at 19:01 UTC 22facc21abe7cceacb93432742df98be608cf170
1 file changed +1 -1
migration/global_state.c
+1 -1
@@ -148,7 +148,7 @@ static const VMStateDescription vmstate_globalstate = {
148 void register_global_state(void)
149 {
150 /* We would use it independently that we receive it */
151 - strcpy((char *)&global_state.runstate, "");
151 + global_state.runstate[0] = '\0';
152 global_state.received = false;
153 vmstate_register(NULL, 0, &vmstate_globalstate, &global_state);
154 }