From nobody Sun May 19 01:26:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1695707598; cv=none; d=zohomail.com; s=zohoarc; b=WjmSdXu/+YrpWI53OXL7eoI305nNWzwc/yhQWW8DDZXr+UiI+H4v+fpPHBMhhYeRy+CZTR344S7kMGWPCGmkRZFyD7E69AF7WAof5seOfwpIzq/Xi5rC6fZTpQ271BKw13EloTYoXGDI9la7IAW5FtvdECu5edR09Gd3W61m6QA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1695707598; 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=BtzSg1OhosbfRyB9z6H/AWYQif8HLMpgoXPBTD5WyJM=; b=acfOmtLQLC2F37SPaIHqfqxS3vtNlWc7gjxvVSO8iYcaBygHAZ3r12eKmNTzZZBlK5e9NbeHEdTeQI4USa7CljxZp9MD1C75LiOkaM77sd0lm1YLWjFtY1ktWCyJ/t9YwrV4dUe+2R17/w+uLEBJdUs4zgR/RLdWtN2BK4IhdvY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1695707598353253.57713227904537; Mon, 25 Sep 2023 22:53:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ql10J-0004vv-1A; Tue, 26 Sep 2023 01:53:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ql10G-0004vd-V6 for qemu-devel@nongnu.org; Tue, 26 Sep 2023 01:53:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ql10F-0007ZH-6r for qemu-devel@nongnu.org; Tue, 26 Sep 2023 01:53:00 -0400 Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-102-mS-wC955NPqEIQt1oAqn6A-1; Tue, 26 Sep 2023 01:52:56 -0400 Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-690f9c65205so11832171b3a.3 for ; Mon, 25 Sep 2023 22:52:55 -0700 (PDT) Received: from localhost.localdomain ([115.96.197.4]) by smtp.googlemail.com with ESMTPSA id f21-20020a170902e99500b001bc87e6e26bsm9939079plb.222.2023.09.25.22.52.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 22:52:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695707577; 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=BtzSg1OhosbfRyB9z6H/AWYQif8HLMpgoXPBTD5WyJM=; b=Ny/ZFf1/8zxABnf0rl/VIZQa9NuTfAnkr8cYWQgEETVIiPYX4wxbomVA/gxHkiVFFi26qC XcemPzRX5bxT9KxyOBMLZTyzdExo3NVqmH1VXuoZ10zQbzYRP0adpKioJhBYe2x5a+i4Kd KSTz79IF8ZSV412Ha0oty4SWM7votHg= X-MC-Unique: mS-wC955NPqEIQt1oAqn6A-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695707575; x=1696312375; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BtzSg1OhosbfRyB9z6H/AWYQif8HLMpgoXPBTD5WyJM=; b=sgqBvxkkqvfB+Z1N3IPdW4VQmcZfZkaWfgzekTbOPr1qVDgQPPqEWVyW8Qj18CHucQ 4JSQBMoSZoM3LuwI+BhfKV/BwIUFuSFcMCYtV4WhAZmRNg0az/NVQpRQCIRvLVISwkDO RGv6xPXi2ytUFYuNooLOOqAxzUhGOzDx7Y+87UCsARuFPrGnWlZo+j84C31gcNPVrpjM w27iTeuxMVQ3MS2Uyqx1qOK6ntZtNxLt993uo6XB+zh0JE3N04qjVGS9BUH6SWqF+iny 6KHZXzBqJ1Ncl/6gfYaRcRWJnqP+UCK3vKQBqNB80HbmJyoawp4VfN4IJAKs1tLcm7be Ukuw== X-Gm-Message-State: AOJu0YxzS4SiRBz3UZrH6pEEMjVlqArxdkwjOJbI4EuXlNKcxRNCKEK2 9N8duVrdLCyFWmd4Afn6D5eEUT9wCI9wJoJtx2/tlyigG9ubUJVZL5Fvuza1fAWxaHvj8JdDc+2 Zs6q9BuEmkVoj6Eo= X-Received: by 2002:a05:6a21:4843:b0:121:e573:3680 with SMTP id au3-20020a056a21484300b00121e5733680mr8241438pzc.62.1695707575108; Mon, 25 Sep 2023 22:52:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE5WAsJ/48tKYka/tk1bd05fFpeXbP0gVwxFKV47RJToJ1iSKYwTdINcmvPEVa/ZOiiaMd5rQ== X-Received: by 2002:a05:6a21:4843:b0:121:e573:3680 with SMTP id au3-20020a056a21484300b00121e5733680mr8241431pzc.62.1695707574792; Mon, 25 Sep 2023 22:52:54 -0700 (PDT) From: Ani Sinha To: "Michael S. Tsirkin" , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost , Peter Xu , Jason Wang Cc: Ani Sinha , Markus Armbruster , Philippe Mathieu-Daude , =?UTF-8?q?Daniel=20P=20=2E=20Berrang=C3=A9?= , qemu-devel@nongnu.org Subject: [PATCH v2] hw/i386: changes towards enabling -Wshadow=local Date: Tue, 26 Sep 2023 11:22:35 +0530 Message-Id: <20230926055235.9164-1-anisinha@redhat.com> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=170.10.133.124; envelope-from=anisinha@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1695707600329100003 Code changes that addresses all compiler complaints coming from enabling -Wshadow flags. Enabling -Wshadow catches cases of local variables shadowing other local variables or parameters. These makes the code confusing and/or = adds bugs that are difficult to catch. CC: Markus Armbruster CC: Philippe Mathieu-Daude CC: mst@redhat.com Message-Id: <87r0mqlf9x.fsf@pond.sub.org> Signed-off-by: Ani Sinha Reviewed-by: Daniel P. Berrang=C3=A9 Reviewed-by: Peter Xu --- hw/i386/acpi-microvm.c | 12 ++++++------ hw/i386/intel_iommu.c | 8 ++++---- hw/i386/pc.c | 1 - hw/i386/x86.c | 2 -- 4 files changed, 10 insertions(+), 13 deletions(-) changelog: v2: kept Peter's changes from https://lore.kernel.org/r/20230922160410.1387= 86-1-peterx@redhat.com and removed mine. diff --git a/hw/i386/acpi-microvm.c b/hw/i386/acpi-microvm.c index a075360d85..6e4f8061eb 100644 --- a/hw/i386/acpi-microvm.c +++ b/hw/i386/acpi-microvm.c @@ -78,18 +78,18 @@ static void acpi_dsdt_add_virtio(Aml *scope, hwaddr base =3D VIRTIO_MMIO_BASE + index * 512; hwaddr size =3D 512; =20 - Aml *dev =3D aml_device("VR%02u", (unsigned)index); - aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005"))); - aml_append(dev, aml_name_decl("_UID", aml_int(index))); - aml_append(dev, aml_name_decl("_CCA", aml_int(1))); + Aml *adev =3D aml_device("VR%02u", (unsigned)index); + aml_append(adev, aml_name_decl("_HID", aml_string("LNRO0005"))= ); + aml_append(adev, aml_name_decl("_UID", aml_int(index))); + aml_append(adev, aml_name_decl("_CCA", aml_int(1))); =20 Aml *crs =3D aml_resource_template(); aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE)= ); aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_H= IGH, AML_EXCLUSIVE, &irq, 1)); - aml_append(dev, aml_name_decl("_CRS", crs)); - aml_append(scope, dev); + aml_append(adev, aml_name_decl("_CRS", crs)); + aml_append(scope, adev); } } } diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index c0ce896668..2c832ab68b 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -3744,7 +3744,7 @@ VTDAddressSpace *vtd_find_add_as(IntelIOMMUState *s, = PCIBus *bus, /* Unmap the whole range in the notifier's scope. */ static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n) { - hwaddr size, remain; + hwaddr total, remain; hwaddr start =3D n->start; hwaddr end =3D n->end; IntelIOMMUState *s =3D as->iommu_state; @@ -3765,7 +3765,7 @@ static void vtd_address_space_unmap(VTDAddressSpace *= as, IOMMUNotifier *n) } =20 assert(start <=3D end); - size =3D remain =3D end - start + 1; + total =3D remain =3D end - start + 1; =20 while (remain >=3D VTD_PAGE_SIZE) { IOMMUTLBEvent event; @@ -3793,10 +3793,10 @@ static void vtd_address_space_unmap(VTDAddressSpace= *as, IOMMUNotifier *n) trace_vtd_as_unmap_whole(pci_bus_num(as->bus), VTD_PCI_SLOT(as->devfn), VTD_PCI_FUNC(as->devfn), - n->start, size); + n->start, total); =20 map.iova =3D n->start; - map.size =3D size - 1; /* Inclusive */ + map.size =3D total - 1; /* Inclusive */ iova_tree_remove(as->iova_tree, map); } =20 diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 3db0743f31..e7a233e886 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1116,7 +1116,6 @@ void pc_memory_init(PCMachineState *pcms, =20 if (machine->device_memory) { uint64_t *val =3D g_malloc(sizeof(*val)); - PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); uint64_t res_mem_end =3D machine->device_memory->base; =20 if (!pcmc->broken_reserved_end) { diff --git a/hw/i386/x86.c b/hw/i386/x86.c index f034df8bf6..b3d054889b 100644 --- a/hw/i386/x86.c +++ b/hw/i386/x86.c @@ -365,8 +365,6 @@ void x86_cpu_pre_plug(HotplugHandler *hotplug_dev, =20 cpu_slot =3D x86_find_cpu_slot(MACHINE(x86ms), cpu->apic_id, &idx); if (!cpu_slot) { - MachineState *ms =3D MACHINE(x86ms); - x86_topo_ids_from_apicid(cpu->apic_id, &topo_info, &topo_ids); error_setg(errp, "Invalid CPU [socket: %u, die: %u, core: %u, thread: %u] with" --=20 2.39.3