From nobody Fri May 17 11:29:00 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=1615548241; cv=none; d=zohomail.com; s=zohoarc; b=HO1KKi7F4csvAYWJJzXucW/52vhWR1eYlO6p2DyF8MIcICaqGYIKvnrnSGz4e2bvY86TT4LInAwAOXU5MsnoYNDljToOi/D0YFLPiXW4RkaD+h3j2uoumAFe++zr1uuyNXkMZpdzT9nfjtQl932eMbrfU5T6ZXbd9eXFARD/HG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1615548241; 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=PyZl5yNYCzmSlncz2icx83BfKH5WAA2KD3Yd7vVvzro=; b=bwmEASbTZgHJvBEsGat3jZ9/EpiUkcwNBnCkicWStadYwBZzSTKmaACJ5oSLHO1cec9zWAnnDGbvYtVEqJJeCToNCdRr2cc/F5p7YShAhs8xRPx+0BhBACMMlLx1KTQx1yA9ZGaXDBWoj6Ps0kKAUE8zwIpcEYob5dh9FU2qXoY= 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 1615548241223397.87473564817753; Fri, 12 Mar 2021 03:24:01 -0800 (PST) Received: from localhost ([::1]:57192 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lKftg-00080r-1d for importer@patchew.org; Fri, 12 Mar 2021 06:24:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKfsK-0006vk-3L; Fri, 12 Mar 2021 06:22:36 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:3935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lKfsG-0002u0-S2; Fri, 12 Mar 2021 06:22:35 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4Dxjyq2P01zNlsR; Fri, 12 Mar 2021 19:20:03 +0800 (CST) Received: from DESKTOP-8RFUVS3.china.huawei.com (10.174.185.179) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.498.0; Fri, 12 Mar 2021 19:22:11 +0800 From: Zenghui Yu To: , , Subject: [PATCH v3] multi-process: Initialize variables declared with g_auto* Date: Fri, 12 Mar 2021 19:21:43 +0800 Message-ID: <20210312112143.1369-1-yuzenghui@huawei.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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.191; envelope-from=yuzenghui@huawei.com; helo=szxga05-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_H2=-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: berrange@redhat.com, qemu-trivial@nongnu.org, mjt@tls.msk.ru, qemu-devel@nongnu.org, laurent@vivier.eu, Zenghui Yu , wanghaibin.wang@huawei.com, philmd@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" 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 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 Reviewed-by: Miroslav Rezanina --- * From v2: - Add OS distro and compiler version into commit message - Add Philippe's R-b - Cc: qemu-trivial@nongnu.org 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