From nobody Tue Apr 16 06:46:41 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) client-ip=209.132.183.24; envelope-from=libvir-list-bounces@redhat.com; helo=mx3-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.24 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by mx.zohomail.com with SMTPS id 1487707307322554.5965974141667; Tue, 21 Feb 2017 12:01:47 -0800 (PST) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LJw6pO026115; Tue, 21 Feb 2017 14:58:06 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LJvpgf020752 for ; Tue, 21 Feb 2017 14:57:51 -0500 Received: from inaba.usersys.redhat.com (ovpn-204-99.brq.redhat.com [10.40.204.99]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LJvjbE002979 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 21 Feb 2017 14:57:50 -0500 From: Andrea Bolognani To: libvir-list@redhat.com Date: Tue, 21 Feb 2017 20:57:41 +0100 Message-Id: <1487707064-29602-4-git-send-email-abologna@redhat.com> In-Reply-To: <1487707064-29602-1-git-send-email-abologna@redhat.com> References: <1487707064-29602-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] conf: Make switch statements more strict X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When switching over the values in the virDomainControllerModelPCI enumeration, make sure the proper cast is in place so that the compiler can warn us when the coverage is not exaustive. For the same reason, remove the 'default' case from one of the existing switch statements. --- src/conf/domain_addr.c | 4 ++-- src/conf/domain_conf.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 519cc6b..933c2fe 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -344,9 +344,9 @@ virDomainPCIAddressBusSetModel(virDomainPCIAddressBusPt= r bus, bus->maxSlot =3D VIR_PCI_ADDRESS_SLOT_LAST; break; =20 - default: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: virReportError(VIR_ERR_INTERNAL_ERROR, - _("Invalid PCI controller model %d"), model); + _("PCI controller model was not set correctly")); return -1; } =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79bdbdf..3ac8467 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8834,7 +8834,7 @@ virDomainControllerDefParseXML(xmlNodePtr node, break; } case VIR_DOMAIN_CONTROLLER_TYPE_PCI: - switch (def->model) { + switch ((virDomainControllerModelPCI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT: { unsigned long long bytes; @@ -8859,6 +8859,16 @@ virDomainControllerDefParseXML(xmlNodePtr node, def->opts.pciopts.pcihole64 =3D true; def->opts.pciopts.pcihole64size =3D VIR_DIV_UP(bytes, 1024); } + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_UPSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_EXPANDER_BUS: + case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST: + /* Other controller models don't require extra checks */ + break; } if (modelName && (def->opts.pciopts.modelName --=20 2.7.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list