From nobody Fri May 17 10:44:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1614824290; cv=none; d=zohomail.com; s=zohoarc; b=WQ1rWTA8HQ92nfM3s8BRix8g2fHw5rLsPnFfV+Z4X59py6sOGlqXv7VSpoisfm40F7FCvc3jK1qs43CdLs3s0W4+3h55OoPHew4C5K6xBa+ngOWiafYrkuq7RQqyiXKBYIFSOMQxTudG3ph1kCEZ12cMj4IsrO9Zd/HDZJ2eiTY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1614824290; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=CPnXIdS9kMEOGMLgAf7QnqAbIJ5Nney0qLb/vuPgAuU=; b=jS8fYZg40P0mH9buTYenBQ8BB1E8TQeajJbjtM7hR1omdru3mZwfbNrqQLe+GxCibvgHrvzL23bCNIN75cGGHiKk8B/E6EUwH1Ogawn4I9/uaYaj1gjJPQuP2C586/s/dQBm63vU1LpfHMC0Eyg/OBuc+xgkkoCZqxTZI33EkIE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1614824290467477.14777097109913; Wed, 3 Mar 2021 18:18:10 -0800 (PST) Received: from localhost ([::1]:53882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lHdZ3-000061-F5 for importer@patchew.org; Wed, 03 Mar 2021 21:18:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHdXu-0007ii-Ov for qemu-devel@nongnu.org; Wed, 03 Mar 2021 21:16:58 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:3376) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lHdXr-0006mG-4K for qemu-devel@nongnu.org; Wed, 03 Mar 2021 21:16:58 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4DrZFn0Zcwz16G3N; Thu, 4 Mar 2021 10:15:09 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.179) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.498.0; Thu, 4 Mar 2021 10:16:44 +0800 From: Zenghui Yu To: , , Subject: [PATCH v2] multi-process: Initialize variables declared with g_auto* Date: Thu, 4 Mar 2021 10:16:21 +0800 Message-ID: <20210304021621.579-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.185.179] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.190; envelope-from=yuzenghui@huawei.com; helo=szxga04-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zenghui Yu , philmd@redhat.com, berrange@redhat.com, qemu-devel@nongnu.org, wanghaibin.wang@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" 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: ../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 u= sed uninitialized in this function [-Werror=3Dmaybe-uninitialized] g_free (*pp); ^~~~~~~~~~~~ ../hw/remote/proxy.c:350:30: note: 'name' was declared here g_autofree char *name; ^~~~ Signed-off-by: Zenghui Yu Reviewed-by: Jagannathan Raman Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- * From v1: - Move the suffix iteration out of the loop (Philippe) - Add Jagannathan's R-b hw/remote/memory.c | 5 ++--- hw/remote/proxy.c | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/hw/remote/memory.c b/hw/remote/memory.c index 32085b1e05..d97947d4b8 100644 --- a/hw/remote/memory.c +++ b/hw/remote/memory.c @@ -42,10 +42,9 @@ void remote_sysmem_reconfig(MPQemuMsg *msg, Error **errp) =20 remote_sysmem_reset(); =20 - for (region =3D 0; region < msg->num_fds; region++) { - g_autofree char *name; + for (region =3D 0; region < msg->num_fds; region++, suffix++) { + g_autofree char *name =3D g_strdup_printf("remote-mem-%u", suffix); subregion =3D g_new(MemoryRegion, 1); - name =3D g_strdup_printf("remote-mem-%u", suffix++); memory_region_init_ram_from_fd(subregion, NULL, name, sysmem_info->sizes[region], true, msg->fds[region], diff --git a/hw/remote/proxy.c b/hw/remote/proxy.c index 4fa4be079d..6dda705fc2 100644 --- a/hw/remote/proxy.c +++ b/hw/remote/proxy.c @@ -347,13 +347,12 @@ static void probe_pci_info(PCIDevice *dev, Error **er= rp) PCI_BASE_ADDRESS_SPACE_IO : PCI_BASE_ADDRESS_SPACE_MEMO= RY; =20 if (size) { - g_autofree char *name; + g_autofree char *name =3D g_strdup_printf("bar-region-%d", i); pdev->region[i].dev =3D pdev; pdev->region[i].present =3D true; if (type =3D=3D PCI_BASE_ADDRESS_SPACE_MEMORY) { pdev->region[i].memory =3D true; } - name =3D g_strdup_printf("bar-region-%d", i); memory_region_init_io(&pdev->region[i].mr, OBJECT(pdev), &proxy_mr_ops, &pdev->region[i], name, size); --=20 2.19.1