aboutsummaryrefslogtreecommitdiff
path: root/hw/remote/memory.c
diff options
context:
space:
mode:
authorZenghui Yu <yuzenghui@huawei.com>2021-03-12 19:21:43 +0800
committerStefan Hajnoczi <stefanha@redhat.com>2021-05-21 15:43:57 +0100
commitd90226808b5b1b30b07968e94d8f74bf8804fc89 (patch)
tree09431e51cdb86a08cd3b3f1371d3d49b934a1dc4 /hw/remote/memory.c
parent6c769690ac845fa62642a5f93b4e4bd906adab95 (diff)
downloadqemu-d90226808b5b1b30b07968e94d8f74bf8804fc89.zip
qemu-d90226808b5b1b30b07968e94d8f74bf8804fc89.tar.gz
qemu-d90226808b5b1b30b07968e94d8f74bf8804fc89.tar.bz2
multi-process: Initialize variables declared with g_auto*
Quote docs/devel/style.rst (section "Automatic memory deallocation"): * Variables declared with g_auto* MUST always be initialized, otherwise the cleanup function will use uninitialized stack memory Initialize @name properly to get rid of the compilation error (using gcc-7.3.0 on CentOS): ../hw/remote/proxy.c: In function 'pci_proxy_dev_realize': /usr/include/glib-2.0/glib/glib-autocleanups.h:28:3: error: 'name' may be used uninitialized in this function [-Werror=maybe-uninitialized] g_free (*pp); ^~~~~~~~~~~~ ../hw/remote/proxy.c:350:30: note: 'name' was declared here g_autofree char *name; ^~~~ Signed-off-by: Zenghui Yu <yuzenghui@huawei.com> Reviewed-by: Jagannathan Raman <jag.raman@oracle.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Miroslav Rezanina <mrezanin@redhat.com> Message-id: 20210312112143.1369-1-yuzenghui@huawei.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Diffstat (limited to 'hw/remote/memory.c')
-rw-r--r--hw/remote/memory.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/hw/remote/memory.c b/hw/remote/memory.c
index 2d41746..472ed2a 100644
--- a/hw/remote/memory.c
+++ b/hw/remote/memory.c
@@ -41,10 +41,9 @@ void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp)
remote_sysmem_reset();
- for (region = 0; region < msg->num_fds; region++) {
- g_autofree char *name;
+ for (region = 0; region < msg->num_fds; region++, suffix++) {
+ g_autofree char *name = g_strdup_printf("remote-mem-%u", suffix);
subregion = g_new(MemoryRegion, 1);
- name = g_strdup_printf("remote-mem-%u", suffix++);
memory_region_init_ram_from_fd(subregion, NULL,
name, sysmem_info->sizes[region],
true, msg->fds[region],