All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Guo <guobin@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: peterx@redhat.com, farosas@suse.de
Subject: [PATCH 2/8] migration/global_state: replace strcpy("") with explicit NUL termination
Date: Mon, 18 May 2026 18:51:49 +0800	[thread overview]
Message-ID: <20260518105156.17626-3-guobin@linux.alibaba.com> (raw)
In-Reply-To: <20260518105156.17626-1-guobin@linux.alibaba.com>

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>
---
 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 c1f90fce0f..91fefdf525 100644
--- a/migration/global_state.c
+++ b/migration/global_state.c
@@ -148,7 +148,7 @@ static const VMStateDescription vmstate_globalstate = {
 void register_global_state(void)
 {
     /* We would use it independently that we receive it */
-    strcpy((char *)&global_state.runstate, "");
+    global_state.runstate[0] = '\0';
     global_state.received = false;
     vmstate_register(NULL, 0, &vmstate_globalstate, &global_state);
 }
-- 
2.50.1 (Apple Git-155)



  parent reply	other threads:[~2026-05-18 10:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-18 10:51 [PATCH 0/8] migration: cleanups, fixes and micro-optimizations Bin Guo
2026-05-18 10:51 ` [PATCH 1/8] migration/fd: collapse migration_fd_valid into single boolean expression Bin Guo
2026-05-18 10:51 ` Bin Guo [this message]
2026-05-18 10:51 ` [PATCH 3/8] migration/vmstate: avoid per-element heap churn in vmsd ptr marker field Bin Guo
  -- strict thread matches above, loose matches on Subject: below --
2026-05-18 11:01 [PATCH 0/8] migration: cleanups, fixes and micro-optimizations Bin Guo
2026-05-18 11:01 ` [PATCH 2/8] migration/global_state: replace strcpy("") with explicit NUL termination Bin Guo
2026-05-18 20:32   ` Fabiano Rosas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260518105156.17626-3-guobin@linux.alibaba.com \
    --to=guobin@linux.alibaba.com \
    --cc=farosas@suse.de \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.