From nobody Mon Apr 29 13:00:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1604744987; cv=none; d=zohomail.com; s=zohoarc; b=lz4GxCaswJKNcdfgPgj76pxvbEzrEnNLcUw2lKCjdcMo39602fBZBe3SyZBDV1mcoyB23tcgmsOy7IvDuyHPsvUAv1OoGqpPsu2VCZJ7cxIFfaGiJji9bxTXRbNyOiM44Vdb+4cMIa8SrpOx/C/xFXxoTJZyDmmv4+LuLuKhPik= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604744987; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:MIME-Version:Message-ID:Subject:To; bh=uInZETVFzGVp4B1joHW83HQLyzc0pckzDCUpFpOUF7A=; b=eoUCu6Hjw7+0Pa4OXEcc2I+5QdoS9ago5xTB1xrGKgE/INvXlNKEo9y24obqknm3Rg1/qrlHl9uNjTDx5SeMJTgyEExb5DCppVyVaUZ9PxUg8IUExcEcxob5Ujw0+JQil6eBgtYIrUwa6Z3m/HNKYyPZyk1Tl37x+05VWa/hI+4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1604744987175222.39511883940986; Sat, 7 Nov 2020 02:29:47 -0800 (PST) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-qhnE4jP8PTa9ovioMzO8rQ-1; Sat, 07 Nov 2020 05:29:44 -0500 Received: by mail-wm1-f72.google.com with SMTP id c10so1277873wmh.6 for ; Sat, 07 Nov 2020 02:29:44 -0800 (PST) Return-Path: Return-Path: Received: from localhost.localdomain (234.red-83-42-66.dynamicip.rima-tde.net. [83.42.66.234]) by smtp.gmail.com with ESMTPSA id v189sm6342038wmg.14.2020.11.07.02.29.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Nov 2020 02:29:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604744985; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uInZETVFzGVp4B1joHW83HQLyzc0pckzDCUpFpOUF7A=; b=dlyhgYGsVONdKBLuoPZHv3oRwJza6qxAT1/9RC5QWu2LBnUEwsIVsJWIB2/lk9rvc/dhjM xt56yY7xCJ0hSAPPyc9YmGo8f4sP6iWOs4pDI7gJKL5zVVspirTnsQay3Ctsp6eTvoA+RQ MvrW4EBkHnVlMfm81RLRK5nSun0S0ZI= X-MC-Unique: qhnE4jP8PTa9ovioMzO8rQ-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=uInZETVFzGVp4B1joHW83HQLyzc0pckzDCUpFpOUF7A=; b=ZFslTUClxTZ/8ofgg/GjP8XXZ8S1fwHxsTfj+GJ8zSrwTF6EFPlzWVQob8eD65DLJB /tlNZ5lEp7T4qbxjaMWhTYAirX6zKRB5bxKLXPYkcUFOqsTnIRdwfnEilhPrtIEukcoU MjwY1OOQ9v+MlDBdohsk5B/Tn52JlGhu5o798OF5eQSZCP8ACrMSjk1pg0vAwKEke3mN nLGxMfJFnTDrsBC/sTV8H/sA7lx6t3/enjjII+pZVF4czutkUMaeQ27aaUGP9Gzwmnm+ 1IY5RgyJRY0u4rDn07wcGAiEmiJsSXRrqc6ljKec0tufsVaPL+x4XUYFnfUDwTzC7TIb xsxg== X-Gm-Message-State: AOAM530I1d8S+GXsXiZI9oGjhnvk6PLSDbcxH50457+2VRxLs2Fvsqaq OojsjtNLZp1XYuZ0HaBnGExDbybmmINrMHA0aeTqk4C5CcXBx6yJCqKQqgaOH8Uc896LX8w3721 rr/I4USjcfkhuHw== X-Received: by 2002:adf:9461:: with SMTP id 88mr7044881wrq.171.1604744983114; Sat, 07 Nov 2020 02:29:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwchHDpcRXSmU6ZYmLLMpxS51oaqlE5FRn7ZgBDg1Ze4J5FcLK3ffU7Nkf3zhgfCR46pNf60w== X-Received: by 2002:adf:9461:: with SMTP id 88mr7044865wrq.171.1604744982951; Sat, 07 Nov 2020 02:29:42 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Michael S . Tsirkin" , Paolo Bonzini , Igor Mammedov , Ani Sinha , Eduardo Habkost , Marcel Apfelbaum , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [RFC PATCH-for-5.2] hw/i386/acpi-build: Fix maybe-uninitialized error when ACPI hotplug off Date: Sat, 7 Nov 2020 11:29:40 +0100 Message-Id: <20201107102940.239877-1-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) 'method' can be left uninitialized. Restrict some code to be used only in the "if (bsel || pcihp_bridge_en)" block statement. This fixes (gcc 9.3.0 on Ubuntu): ../hw/i386/acpi-build.c: In function 'build_append_pci_bus_devices': ../hw/i386/acpi-build.c:496:9: error: 'method' may be used uninitialized in this function [-Werror=3Dmaybe-uninitialized] 496 | aml_append(parent_scope, method); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Fixes: df4008c9c59 ("piix4: don't reserve hw resources when hotplug is off = globally") Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- RFC because I have no clue about this code --- hw/i386/acpi-build.c | 45 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4f66642d887..1f5c2112452 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -465,34 +465,31 @@ static void build_append_pci_bus_devices(Aml *parent_= scope, PCIBus *bus, */ if (bsel || pcihp_bridge_en) { method =3D aml_method("PCNT", 0, AML_NOTSERIALIZED); - } - /* If bus supports hotplug select it and notify about local events */ - if (bsel) { - uint64_t bsel_val =3D qnum_get_uint(qobject_to(QNum, bsel)); =20 - aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM"))); - aml_append(method, - aml_call2("DVNT", aml_name("PCIU"), aml_int(1) /* Device Check= */) - ); - aml_append(method, - aml_call2("DVNT", aml_name("PCID"), aml_int(3)/* Eject Request= */) - ); - } + /* If bus supports hotplug select it and notify about local events= */ + if (bsel) { + uint64_t bsel_val =3D qnum_get_uint(qobject_to(QNum, bsel)); =20 - /* Notify about child bus events in any case */ - if (pcihp_bridge_en) { - QLIST_FOREACH(sec, &bus->child, sibling) { - int32_t devfn =3D sec->parent_dev->devfn; - - if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) { - continue; - } - - aml_append(method, aml_name("^S%.02X.PCNT", devfn)); + aml_append(method, aml_store(aml_int(bsel_val), aml_name("BNUM= "))); + aml_append(method, aml_call2("DVNT", aml_name("PCIU"), + aml_int(1))); /* Device Check */ + aml_append(method, aml_call2("DVNT", aml_name("PCID"), + aml_int(3))); /* Eject Request */ + } + + /* Notify about child bus events in any case */ + if (pcihp_bridge_en) { + QLIST_FOREACH(sec, &bus->child, sibling) { + int32_t devfn =3D sec->parent_dev->devfn; + + if (pci_bus_is_root(sec) || pci_bus_is_express(sec)) { + continue; + } + + aml_append(method, aml_name("^S%.02X.PCNT", devfn)); + } } - } =20 - if (bsel || pcihp_bridge_en) { aml_append(parent_scope, method); } qobject_unref(bsel); --=20 2.26.2