From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146513062680.2811315643603; Tue, 20 Feb 2018 09:08:33 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8BB9C6AAE7; Tue, 20 Feb 2018 17:08:31 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 093F15D70C; Tue, 20 Feb 2018 17:08:31 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D6A0F4A46D; Tue, 20 Feb 2018 17:08:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8SWw009622 for ; Tue, 20 Feb 2018 12:08:28 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1E319AE7B6; Tue, 20 Feb 2018 17:08:28 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3141AE7BD; Tue, 20 Feb 2018 17:08:27 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:09 +0000 Message-Id: <20180220170822.16462-2-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 01/14] util: add a virReportEnumRangeError for bad value reporting 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Feb 2018 17:08:32 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 To ensure we have standardized error messages when reporting problems with enum values being out of a range, add virReportEnumRangeError(). virReportEnumRangeError(virDomainState, 34); results in a message "internal error: Unexpected enum value 34 for virDomainState" Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/util/virerror.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/util/virerror.h b/src/util/virerror.h index cf434f45fc..1d02451604 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -164,7 +164,14 @@ void virReportSystemErrorFull(int domcode, # define virReportRestrictedError(...) \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_OPERATION_DENIED, \ __FILE__, __FUNCTION__, __LINE__, __VA_ARGS__) - +/* The sizeof(typname) comparison here is a hack to catch typos + * in the name of the enum by triggering a compile error. It should + * get optimized away since sizeof() is known at compile time */ +# define virReportEnumRangeError(typname, value) \ + virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, \ + __FILE__, __FUNCTION__, __LINE__, \ + "Unexpected enum value %d for %s", \ + value, sizeof(typname) !=3D 0 ? #typname : #typna= me); =20 void virReportOOMErrorFull(int domcode, const char *filename, --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146618313182.06181482591182; Tue, 20 Feb 2018 09:10:18 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAC397E423; Tue, 20 Feb 2018 17:10:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97FAC6090C; Tue, 20 Feb 2018 17:10:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 50AC418033F5; Tue, 20 Feb 2018 17:10:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8THI009631 for ; Tue, 20 Feb 2018 12:08:29 -0500 Received: by smtp.corp.redhat.com (Postfix) id 70CFAAE7BA; Tue, 20 Feb 2018 17:08:29 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52E9FAE7B9; Tue, 20 Feb 2018 17:08:28 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:10 +0000 Message-Id: <20180220170822.16462-3-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 02/14] util: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 20 Feb 2018 17:10:17 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. Reviewed-by: John Ferlan Signed-off-by: Daniel P. Berrang=C3=A9 --- src/util/virconf.c | 11 ++++++++++- src/util/virfirewall.c | 6 ++++-- src/util/virlog.c | 9 ++++++++- src/util/virnetdevvportprofile.c | 10 +++++++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/util/virconf.c b/src/util/virconf.c index a82a509ca3..e0a3fd12c0 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -296,7 +296,9 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val) virBufferAddLit(buf, " ]"); break; } + case VIR_CONF_LAST: default: + virReportEnumRangeError(virConfType, val->type); return -1; } return 0; @@ -986,13 +988,20 @@ int virConfGetValueStringList(virConfPtr conf, } ATTRIBUTE_FALLTHROUGH; =20 - default: + case VIR_CONF_LLONG: + case VIR_CONF_ULLONG: + case VIR_CONF_NONE: virReportError(VIR_ERR_INTERNAL_ERROR, compatString ? _("%s: expected a string or string list for '%s' pa= rameter") : _("%s: expected a string list for '%s' parameter"), conf->filename, setting); return -1; + + case VIR_CONF_LAST: + default: + virReportEnumRangeError(virConfType, cval->type); + return -1; } =20 return 1; diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index ff1bb83073..10c370a2ae 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -827,9 +827,11 @@ virFirewallApplyRule(virFirewallPtr firewall, if (virFirewallApplyRuleFirewallD(rule, ignoreErrors, &output) < 0) return -1; break; + + case VIR_FIREWALL_BACKEND_AUTOMATIC: + case VIR_FIREWALL_BACKEND_LAST: default: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unexpected firewall engine backend")); + virReportEnumRangeError(virFirewallBackend, currentBackend); return -1; } =20 diff --git a/src/util/virlog.c b/src/util/virlog.c index 4f66cc5e5c..6c6d7e8ded 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1206,10 +1206,17 @@ virLogGetOutputs(void) virLogDestinationTypeToString(dest), virLogOutputs[i]->name); break; - default: + case VIR_LOG_TO_STDERR: + case VIR_LOG_TO_JOURNALD: virBufferAsprintf(&outputbuf, "%d:%s", virLogOutputs[i]->priority, virLogDestinationTypeToString(dest)); + break; + case VIR_LOG_TO_OUTPUT_LAST: + default: + virReportEnumRangeError(virLogDestination, dest); + virLogUnlock(); + return NULL; } } virLogUnlock(); diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprof= ile.c index db495a7549..dc774407df 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -1071,6 +1071,9 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname, case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE: op =3D PORT_REQUEST_PREASSOCIATE; break; + case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE_RR: + op =3D PORT_REQUEST_PREASSOCIATE_RR; + break; case VIR_NETDEV_VPORT_PROFILE_LINK_OP_ASSOCIATE: op =3D PORT_REQUEST_ASSOCIATE; break; @@ -1191,10 +1194,15 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname, false); break; =20 - default: + case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE: virReportError(VIR_ERR_INTERNAL_ERROR, _("operation type %d not supported"), virtPortOp); rc =3D -1; + break; + default: + virReportEnumRangeError(virNetDevVPortProfile, virtPortOp); + rc =3D -1; + break; } =20 cleanup: --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146621236382.5210501343636; Tue, 20 Feb 2018 09:10:21 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EB595C05E74C; Tue, 20 Feb 2018 17:10:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B943F5D969; Tue, 20 Feb 2018 17:10:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 82C8A18033FA; Tue, 20 Feb 2018 17:10:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8U7M009640 for ; Tue, 20 Feb 2018 12:08:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 20FE1AE7BA; Tue, 20 Feb 2018 17:08:30 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id A59D6AE7B9; Tue, 20 Feb 2018 17:08:29 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:11 +0000 Message-Id: <20180220170822.16462-4-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 03/14] conf: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Feb 2018 17:10:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/conf/domain_audit.c | 1 + src/conf/domain_conf.c | 46 ++++++++++++++++++++++++++++++++++++++++----= -- src/conf/nwfilter_conf.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 71 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c index 723c737363..82868bca76 100644 --- a/src/conf/domain_audit.c +++ b/src/conf/domain_audit.c @@ -586,6 +586,7 @@ virDomainAuditTPM(virDomainObjPtr vm, virDomainTPMDefPt= r tpm, "virt=3D%s resrc=3Ddev reason=3D%s %s uuid=3D%s %s", virt, reason, vmname, uuidstr, device); break; + case VIR_DOMAIN_TPM_TYPE_LAST: default: break; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 68a8d39016..f2ddde7a36 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11567,8 +11567,20 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlo= pt, def->filterparams =3D filterparams; filterparams =3D NULL; break; - default: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: break; + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, def->type); + goto error; } } =20 @@ -14703,6 +14715,12 @@ virDomainVideoDefaultRAM(const virDomainDef *def, /* QEMU use 64M as the minimal video memory for qxl device */ return 64 * 1024; =20 + case VIR_DOMAIN_VIDEO_TYPE_DEFAULT: + case VIR_DOMAIN_VIDEO_TYPE_VBOX: + case VIR_DOMAIN_VIDEO_TYPE_PARALLELS: + case VIR_DOMAIN_VIDEO_TYPE_VIRTIO: + case VIR_DOMAIN_VIDEO_TYPE_GOP: + case VIR_DOMAIN_VIDEO_TYPE_LAST: default: return 0; } @@ -14737,6 +14755,16 @@ virDomainVideoDefaultType(const virDomainDef *def) return VIR_DOMAIN_VIDEO_TYPE_PARALLELS; case VIR_DOMAIN_VIRT_BHYVE: return VIR_DOMAIN_VIDEO_TYPE_GOP; + case VIR_DOMAIN_VIRT_QEMU: + case VIR_DOMAIN_VIRT_KQEMU: + case VIR_DOMAIN_VIRT_KVM: + case VIR_DOMAIN_VIRT_LXC: + case VIR_DOMAIN_VIRT_UML: + case VIR_DOMAIN_VIRT_OPENVZ: + case VIR_DOMAIN_VIRT_HYPERV: + case VIR_DOMAIN_VIRT_PHYP: + case VIR_DOMAIN_VIRT_NONE: + case VIR_DOMAIN_VIRT_LAST: default: return VIR_DOMAIN_VIDEO_TYPE_DEFAULT; } @@ -27878,7 +27906,7 @@ virDomainObjGetState(virDomainObjPtr dom, int *reas= on) void virDomainObjSetState(virDomainObjPtr dom, virDomainState state, int reason) { - int last =3D -1; + int last; =20 switch (state) { case VIR_DOMAIN_NOSTATE: @@ -27905,11 +27933,8 @@ virDomainObjSetState(virDomainObjPtr dom, virDomai= nState state, int reason) case VIR_DOMAIN_PMSUSPENDED: last =3D VIR_DOMAIN_PMSUSPENDED_LAST; break; + case VIR_DOMAIN_LAST: default: - last =3D -1; - } - - if (last < 0) { VIR_ERROR(_("invalid domain state: %d"), state); return; } @@ -28073,6 +28098,15 @@ virDomainNetGetActualVirtPortProfile(virDomainNetD= efPtr iface) default: return NULL; } + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_LAST: default: return NULL; } diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 5d6423e060..fd42d58c2c 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2153,8 +2153,34 @@ virNWFilterRuleValidate(virNWFilterRuleDefPtr rule) } } break; - default: + case VIR_NWFILTER_RULE_PROTOCOL_NONE: + case VIR_NWFILTER_RULE_PROTOCOL_MAC: + case VIR_NWFILTER_RULE_PROTOCOL_VLAN: + case VIR_NWFILTER_RULE_PROTOCOL_STP: + case VIR_NWFILTER_RULE_PROTOCOL_ARP: + case VIR_NWFILTER_RULE_PROTOCOL_RARP: + case VIR_NWFILTER_RULE_PROTOCOL_TCP: + case VIR_NWFILTER_RULE_PROTOCOL_ICMP: + case VIR_NWFILTER_RULE_PROTOCOL_IGMP: + case VIR_NWFILTER_RULE_PROTOCOL_UDP: + case VIR_NWFILTER_RULE_PROTOCOL_UDPLITE: + case VIR_NWFILTER_RULE_PROTOCOL_ESP: + case VIR_NWFILTER_RULE_PROTOCOL_AH: + case VIR_NWFILTER_RULE_PROTOCOL_SCTP: + case VIR_NWFILTER_RULE_PROTOCOL_ALL: + case VIR_NWFILTER_RULE_PROTOCOL_TCPoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_ICMPV6: + case VIR_NWFILTER_RULE_PROTOCOL_UDPoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_UDPLITEoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_ESPoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_AHoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_SCTPoIPV6: + case VIR_NWFILTER_RULE_PROTOCOL_ALLoIPV6: break; + case VIR_NWFILTER_RULE_PROTOCOL_LAST: + default: + virReportEnumRangeError(virNWFilterRuleProtocolType, rule->prtclTy= pe); + return -1; } =20 return ret; @@ -3064,7 +3090,10 @@ virNWFilterRuleDefDetailsFormat(virBufferPtr buf, virBufferAddLit(buf, "false"); break; =20 + case DATATYPE_IPSETNAME: + case DATATYPE_IPSETFLAGS: case DATATYPE_STRING: + case DATATYPE_LAST: default: virBufferAsprintf(buf, "UNSUPPORTED DATATYPE 0x%02x\n", --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146568615655.0183354048065; Tue, 20 Feb 2018 09:09:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1375A7EA83; Tue, 20 Feb 2018 17:09:27 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CD6885D996; Tue, 20 Feb 2018 17:09:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 98FDC4A479; Tue, 20 Feb 2018 17:09:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8UHJ009660 for ; Tue, 20 Feb 2018 12:08:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id C4F20AE7BA; Tue, 20 Feb 2018 17:08:30 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 55E54AE7B9; Tue, 20 Feb 2018 17:08:30 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:12 +0000 Message-Id: <20180220170822.16462-5-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 04/14] esx: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 20 Feb 2018 17:09:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements, or explicitly cast away enum type where we don't want to list all cases. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/esx/esx_driver.c | 1 + src/esx/esx_vi.c | 11 +++++++---- src/esx/esx_vi_types.c | 9 +++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index f575362059..c5f04efa81 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -3603,6 +3603,7 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr dom= ain, params[i].value.i =3D -3; break; =20 + case esxVI_SharesLevel_Undefined: default: virReportError(VIR_ERR_INTERNAL_ERROR, _("Shares level has unknown value %d"), diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index edf52ff828..103f726069 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -483,7 +483,7 @@ esxVI_SharedCURL_Lock(CURL *handle ATTRIBUTE_UNUSED, cu= rl_lock_data data, size_t i; esxVI_SharedCURL *shared =3D userptr; =20 - switch (data) { + switch ((int)data) { case CURL_LOCK_DATA_SHARE: i =3D 0; break; @@ -511,7 +511,7 @@ esxVI_SharedCURL_Unlock(CURL *handle ATTRIBUTE_UNUSED, = curl_lock_data data, size_t i; esxVI_SharedCURL *shared =3D userptr; =20 - switch (data) { + switch ((int)data) { case CURL_LOCK_DATA_SHARE: i =3D 0; break; @@ -1563,6 +1563,7 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char = *methodName, =20 break; =20 + case esxVI_Occurrence_Undefined: default: virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Invalid argument (occurrence)")); @@ -2280,9 +2281,11 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, type, root->type); break; =20 + case esxVI_Occurrence_None: + case esxVI_Occurrence_Undefined: default: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Invalid occurrence value")); + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Invalid occurrence value %d"), occurrence); break; } =20 diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index be35af861c..74183f8307 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -544,7 +544,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); =20 #define ESX_VI__TEMPLATE__DISPATCH(_actual_type, _actual_type_name, __type= , \ _dispatch, _error_return) \ - switch (_actual_type) { \ + switch ((int)_actual_type) { \ _dispatch \ \ case esxVI_Type_##__type: \ @@ -690,7 +690,7 @@ VIR_LOG_INIT("esx.esx_vi_types"); return -1; \ } \ \ - switch (type) { \ + switch ((int)type) { \ _dispatch \ \ case esxVI_Type_##__type: \ @@ -967,7 +967,7 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyT= ype *src) goto failure; } =20 - switch (src->type) { + switch ((int)src->type) { case esxVI_Type_Boolean: (*dest)->boolean =3D src->boolean; break; @@ -1071,7 +1071,7 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyT= ype **anyType) (*anyType)->_name =3D number; \ } while (0) =20 - switch ((*anyType)->type) { + switch ((int)(*anyType)->type) { case esxVI_Type_Boolean: if (STREQ((*anyType)->value, "true")) { (*anyType)->boolean =3D esxVI_Boolean_True; @@ -1876,6 +1876,7 @@ esxVI_VirtualMachinePowerState_ConvertToLibvirt case esxVI_VirtualMachinePowerState_Suspended: return VIR_DOMAIN_PAUSED; =20 + case esxVI_VirtualMachinePowerState_Undefined: default: return VIR_DOMAIN_NOSTATE; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146624781139.2994035414432; Tue, 20 Feb 2018 09:10:24 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3C94DACBA; Tue, 20 Feb 2018 17:10:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0958B60C96; Tue, 20 Feb 2018 17:10:23 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B19C318033FD; Tue, 20 Feb 2018 17:10:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8V3w009667 for ; Tue, 20 Feb 2018 12:08:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76E52AE7B9; Tue, 20 Feb 2018 17:08:31 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 052D2AE7BD; Tue, 20 Feb 2018 17:08:30 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:13 +0000 Message-Id: <20180220170822.16462-6-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 05/14] hyperv: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 20 Feb 2018 17:10:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. This improves debug logging integration with openwsman. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/hyperv/hyperv_driver.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index ee94fd3511..e512b626ea 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1656,13 +1656,27 @@ hypervDebugHandler(const char *message, debug_level= _e level, switch (level) { case DEBUG_LEVEL_ERROR: case DEBUG_LEVEL_CRITICAL: - VIR_ERROR(_("openwsman error: %s"), message); + case DEBUG_LEVEL_ALWAYS: + VIR_ERROR(_("openwsman: %s"), message); break; =20 case DEBUG_LEVEL_WARNING: - VIR_WARN("openwsman warning: %s", message); + VIR_WARN("openwsman: %s", message); break; =20 + case DEBUG_LEVEL_MESSAGE: + VIR_INFO("openwsman: %s", message); + break; + + case DEBUG_LEVEL_INFO: + VIR_INFO("openwsman: %s", message); + break; + + case DEBUG_LEVEL_DEBUG: + VIR_DEBUG("openwsman: %s", message); + break; + + case DEBUG_LEVEL_NONE: default: /* Ignore the rest */ break; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146628156142.8601434205167; Tue, 20 Feb 2018 09:10:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CFE0E7C835; Tue, 20 Feb 2018 17:10:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A2A89620A8; Tue, 20 Feb 2018 17:10:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6183E18033FF; Tue, 20 Feb 2018 17:10:26 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8WMv009680 for ; Tue, 20 Feb 2018 12:08:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id 23FDFAE7B8; Tue, 20 Feb 2018 17:08:32 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB761AE7BA; Tue, 20 Feb 2018 17:08:31 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:14 +0000 Message-Id: <20180220170822.16462-7-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 06/14] libxl: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 20 Feb 2018 17:10:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Cast away enum type for libxl schedular constants since we don't want to cover all of them and don't want build to break when new ones are added. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/libxl/libxl_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index be11134fb2..4b52de36f5 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -4497,7 +4497,7 @@ libxlDomainGetSchedulerType(virDomainPtr dom, int *np= arams) =20 if (nparams) *nparams =3D 0; - switch (sched_id) { + switch ((int)sched_id) { case LIBXL_SCHEDULER_SEDF: name =3D "sedf"; break; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146557093697.8072834952486; Tue, 20 Feb 2018 09:09:17 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B1CF75733; Tue, 20 Feb 2018 17:09:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A12A818211; Tue, 20 Feb 2018 17:09:12 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6D9F718033EA; Tue, 20 Feb 2018 17:09:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8WTP009689 for ; Tue, 20 Feb 2018 12:08:32 -0500 Received: by smtp.corp.redhat.com (Postfix) id C62BFAE7BA; Tue, 20 Feb 2018 17:08:32 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 58AB3AE7B9; Tue, 20 Feb 2018 17:08:32 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:15 +0000 Message-Id: <20180220170822.16462-8-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 07/14] lxc: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 20 Feb 2018 17:09:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements, or cast away enum type in places where we don't wish to cover all cases. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/lxc/lxc_container.c | 8 ++++---- src/lxc/lxc_controller.c | 8 +++++++- src/lxc/lxc_driver.c | 38 ++++++++++++++++++++++++++++++++++---- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 96fceaf1b8..14928e8ece 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -2035,7 +2035,7 @@ static int lxcContainerDropCapabilities(virDomainDefP= tr def, break; =20 case VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT: - switch ((virDomainCapsFeature) i) { + switch (i) { case VIR_DOMAIN_CAPS_FEATURE_SYS_BOOT: /* No use of reboot */ toDrop =3D !keepReboot && (state !=3D VIR_TRISTATE_SWITCH_= ON); break; @@ -2066,10 +2066,10 @@ static int lxcContainerDropCapabilities(virDomainDe= fPtr def, } break; =20 + case VIR_DOMAIN_CAPABILITIES_POLICY_LAST: default: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported capabilities policy: %s"), - virDomainCapabilitiesPolicyTypeToString(policy)= ); + virReportEnumRangeError(virDomainCapabilitiesPolicy, policy); + return -1; } } =20 diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c index c5e67df938..7346804c18 100644 --- a/src/lxc/lxc_controller.c +++ b/src/lxc/lxc_controller.c @@ -395,8 +395,14 @@ static int virLXCControllerGetNICIndexes(virLXCControl= lerPtr ctrl) case VIR_DOMAIN_NET_TYPE_INTERNAL: case VIR_DOMAIN_NET_TYPE_DIRECT: case VIR_DOMAIN_NET_TYPE_HOSTDEV: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported net type %s"), + virDomainNetTypeToString(ctrl->def->nets[i]->ty= pe)); + goto cleanup; + case VIR_DOMAIN_NET_TYPE_LAST: default: - break; + virReportEnumRangeError(virDomainNetType, ctrl->def->nets[i]->= type); + goto cleanup; } } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 961baa344c..3d5b2254f2 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -3968,10 +3968,21 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, if (!(veth =3D virLXCProcessSetupInterfaceDirect(conn, vm->def, ne= t))) goto cleanup; } break; - default: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Network device type is not supported")); goto cleanup; + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, actualType); + goto cleanup; } /* Set bandwidth or warn if requested and not supported. */ actualBandwidth =3D virDomainNetGetActualBandwidth(net); @@ -4011,6 +4022,15 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn, ignore_value(virNetDevMacVLanDelete(veth)); break; =20 + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_LAST: default: /* no-op */ break; @@ -4446,13 +4466,23 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, * the host side. Further the container can change * the mac address of NIC name, so we can't easily * find out which guest NIC it maps to + */ case VIR_DOMAIN_NET_TYPE_DIRECT: - */ - - default: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only bridged veth devices can be detached")); goto cleanup; + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, actualType); + goto cleanup; } =20 virDomainAuditNet(vm, detach, NULL, "detach", true); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146631510548.6086585505477; Tue, 20 Feb 2018 09:10:31 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D77AD5D675; Tue, 20 Feb 2018 17:10:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A85E06049A; Tue, 20 Feb 2018 17:10:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6AFA7180B61F; Tue, 20 Feb 2018 17:10:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8XlK009699 for ; Tue, 20 Feb 2018 12:08:33 -0500 Received: by smtp.corp.redhat.com (Postfix) id 777C9AE7B9; Tue, 20 Feb 2018 17:08:33 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06A8CAE7B6; Tue, 20 Feb 2018 17:08:32 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:16 +0000 Message-Id: <20180220170822.16462-9-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/14] nwfilter: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 20 Feb 2018 17:10:30 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements, or cast away enum type in places where we don't wish to cover all cases. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/conf/nwfilter_conf.h | 4 ++-- src/nwfilter/nwfilter_ebiptables_driver.c | 17 +++++++++++------ src/nwfilter/nwfilter_learnipaddr.c | 6 +++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index eeec10e67b..f960bf3d56 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -86,7 +86,7 @@ typedef enum { (((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG) =20 /* datatypes appearing in rule attributes */ -enum attrDatatype { +typedef enum attrDatatype { DATATYPE_UINT16 =3D (1 << 0), DATATYPE_UINT8 =3D (1 << 1), DATATYPE_UINT16_HEX =3D (1 << 2), @@ -106,7 +106,7 @@ enum attrDatatype { DATATYPE_IPSETFLAGS =3D (1 << 16), =20 DATATYPE_LAST =3D (1 << 17), -}; +} virNWFilterAttrDataType; =20 # define NWFILTER_MAC_BGA "01:80:c2:00:00:00" =20 diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index b8682a1130..b19b07c845 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -320,11 +320,16 @@ _printDataType(virNWFilterVarCombIterPtr vars, VIR_FREE(flags); break; =20 - default: + case DATATYPE_STRING: + case DATATYPE_STRINGCOPY: + case DATATYPE_BOOLEAN: virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unhandled datatype %x"), item->datatype); + _("Cannot print data type %x"), item->datatype); + return -1; + case DATATYPE_LAST: + default: + virReportEnumRangeError(virNWFilterAttrDataType, item->datatype); return -1; - break; } =20 return 0; @@ -1183,7 +1188,7 @@ _iptablesCreateRuleInstance(virFirewallPtr fw, =20 PRINT_IPT_ROOT_CHAIN(chain, chainPrefix, ifname); =20 - switch (rule->prtclType) { + switch ((int)rule->prtclType) { case VIR_NWFILTER_RULE_PROTOCOL_TCP: case VIR_NWFILTER_RULE_PROTOCOL_TCPoIPV6: fwrule =3D virFirewallAddRule(fw, layer, @@ -1873,7 +1878,7 @@ ebtablesCreateRuleInstance(virFirewallPtr fw, #define INST_ITEM_MASK(S, I, MASK, C) \ INST_ITEM_2PARMS(S, I, MASK, C, "/") =20 - switch (rule->prtclType) { + switch ((int)rule->prtclType) { case VIR_NWFILTER_RULE_PROTOCOL_MAC: fwrule =3D virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, "-t", "nat", @@ -2677,7 +2682,7 @@ ebtablesCreateTmpSubChainFW(virFirewallPtr fw, fwrule =3D virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET, "-t", "nat", "-A", rootchain, NULL); =20 - switch (protoidx) { + switch ((int)protoidx) { case L2_PROTO_MAC_IDX: break; case L2_PROTO_STP_IDX: diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_le= arnipaddr.c index 5b95f0e613..9ca0639576 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -430,7 +430,7 @@ learnIPAddressThread(void *arg) } virBufferAddLit(&buf, "src port 67 and dst port 68"); break; - default: + case DETECT_STATIC: if (techdriver->applyBasicRules(req->ifname, &req->macaddr) < 0) { req->status =3D EINVAL; @@ -438,6 +438,10 @@ learnIPAddressThread(void *arg) } virBufferAsprintf(&buf, "ether host %s or ether dst ff:ff:ff:ff:ff= :ff", macaddr); + break; + default: + req->status =3D EINVAL; + goto done; } =20 if (virBufferError(&buf)) { --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146571887713.554358729378; Tue, 20 Feb 2018 09:09:31 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EF501C05D282; Tue, 20 Feb 2018 17:09:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C478260BEE; Tue, 20 Feb 2018 17:09:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8292B18033F0; Tue, 20 Feb 2018 17:09:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8YvO009714 for ; Tue, 20 Feb 2018 12:08:34 -0500 Received: by smtp.corp.redhat.com (Postfix) id 287C7AE7B6; Tue, 20 Feb 2018 17:08:34 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id ADC77AE7BD; Tue, 20 Feb 2018 17:08:33 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:17 +0000 Message-Id: <20180220170822.16462-10-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 09/14] qemu: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Feb 2018 17:09:31 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements, or cast away enum type in places where we don't wish to cover all cases. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/qemu/qemu_command.c | 26 ++++++++++++++++++-------- src/qemu/qemu_domain.c | 21 +++++++++++++++++++++ src/qemu/qemu_driver.c | 25 +++++++++++++++++-------- src/qemu/qemu_hotplug.c | 33 ++++++++++++++++++++++++++++----- src/qemu/qemu_migration.c | 11 ++++++++++- src/qemu/qemu_process.c | 2 ++ 6 files changed, 96 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 34dda23288..fa0aa5d5c3 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2632,7 +2632,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, case VIR_DOMAIN_CONTROLLER_TYPE_SCSI: switch ((virDomainControllerModelSCSI) def->model) { case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_VIRTIO_SCSI: - switch ((virDomainDeviceAddressType) address_type) { + switch (address_type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW: virBufferAddLit(&buf, "virtio-scsi-ccw"); break; @@ -2684,7 +2684,7 @@ qemuBuildControllerDevStr(const virDomainDef *domainD= ef, break; =20 case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: - switch ((virDomainDeviceAddressType) address_type) { + switch (address_type) { case VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI: virBufferAddLit(&buf, "virtio-serial-pci"); break; @@ -3407,12 +3407,17 @@ qemuBuildNicDevStr(virDomainDefPtr def, case VIR_DOMAIN_NET_VIRTIO_TX_MODE_TIMER: virBufferAddLit(&buf, "timer"); break; + + case VIR_DOMAIN_NET_VIRTIO_TX_MODE_DEFAULT: + break; + + case VIR_DOMAIN_NET_VIRTIO_TX_MODE_LAST: default: /* this should never happen, if it does, we need * to add another case to this switch. */ - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("unrecognized virtio-net-pci 'tx' opt= ion")); + virReportEnumRangeError(virDomainNetVirtioTxModeType, + net->driver.virtio.txmode); goto error; } } else { @@ -6598,7 +6603,7 @@ qemuBuildGlobalControllerCommandLine(virCommandPtr cm= d, bool cap =3D false; bool machine =3D false; =20 - switch ((virDomainControllerModelPCI) cont->model) { + switch (cont->model) { case VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT: hoststr =3D "i440FX-pcihost"; cap =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_I440FX_PCI_HOLE= 64_SIZE); @@ -6941,7 +6946,7 @@ qemuBuildCpuCommandLine(virCommandPtr cmd, if (cpu_flags && !cpu) { const char *default_model; =20 - switch (def->os.arch) { + switch ((int)def->os.arch) { case VIR_ARCH_I686: default_model =3D "qemu32"; break; @@ -6987,7 +6992,7 @@ qemuBuildObsoleteAccelArg(virCommandPtr cmd, bool disableKVM =3D false; bool enableKVM =3D false; =20 - switch (def->virtType) { + switch ((int)def->virtType) { case VIR_DOMAIN_VIRT_QEMU: if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) disableKVM =3D true; @@ -7955,8 +7960,13 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfi= gPtr cfg, case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_CLIENT: virBufferAddLit(&opt, "agent-mouse=3Don,"); break; - default: + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT: break; + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsSpiceMouseMode, + graphics->data.spice.mousemode); + goto error; } } =20 diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index b1308e5a49..8b4efc82de 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -2804,6 +2804,27 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def, addPCIRoot =3D true; break; =20 + case VIR_ARCH_ARMV6L: + case VIR_ARCH_ARMV7B: + case VIR_ARCH_CRIS: + case VIR_ARCH_ITANIUM: + case VIR_ARCH_LM32: + case VIR_ARCH_M68K: + case VIR_ARCH_MICROBLAZE: + case VIR_ARCH_MICROBLAZEEL: + case VIR_ARCH_MIPS: + case VIR_ARCH_MIPSEL: + case VIR_ARCH_MIPS64: + case VIR_ARCH_MIPS64EL: + case VIR_ARCH_OR32: + case VIR_ARCH_PARISC: + case VIR_ARCH_PARISC64: + case VIR_ARCH_PPCLE: + case VIR_ARCH_UNICORE32: + case VIR_ARCH_XTENSA: + case VIR_ARCH_XTENSAEB: + case VIR_ARCH_NONE: + case VIR_ARCH_LAST: default: break; } diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 416567512d..8aa293bf1b 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -3016,13 +3016,8 @@ qemuCompressGetCommand(virQEMUSaveFormat compression) ret =3D virCommandNew(prog); virCommandAddArg(ret, "-dc"); =20 - switch (compression) { - case QEMU_SAVE_FORMAT_LZOP: + if (compression =3D=3D QEMU_SAVE_FORMAT_LZOP) virCommandAddArg(ret, "--ignore-warn"); - break; - default: - break; - } =20 return ret; } @@ -17792,11 +17787,18 @@ qemuDomainOpenGraphics(virDomainPtr dom, case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: protocol =3D "spice"; break; - default: + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Can only open VNC or SPICE graphics backends, no= t %s"), virDomainGraphicsTypeToString(vm->def->graphics[idx= ]->type)); goto endjob; + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsType, + vm->def->graphics[idx]->type); + goto endjob; } =20 if (qemuSecuritySetImageFDLabel(driver->securityManager, vm->def, fd) = < 0) @@ -17856,11 +17858,18 @@ qemuDomainOpenGraphicsFD(virDomainPtr dom, case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: protocol =3D "spice"; break; - default: + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Can only open VNC or SPICE graphics backends, no= t %s"), virDomainGraphicsTypeToString(vm->def->graphics[idx= ]->type)); goto cleanup; + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsType, + vm->def->graphics[idx]->type); + goto cleanup; } =20 if (qemuSecuritySetSocketLabel(driver->securityManager, vm->def) < 0) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 04f4f689a9..f28006e3cd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -2978,11 +2978,24 @@ qemuDomainChangeNetFilter(virDomainObjPtr vm, case VIR_DOMAIN_NET_TYPE_BRIDGE: case VIR_DOMAIN_NET_TYPE_NETWORK: break; - default: + case VIR_DOMAIN_NET_TYPE_USER: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("filters not supported on interfaces of type %s"), virDomainNetTypeToString(virDomainNetGetActualType(= newdev))); return -1; + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, + virDomainNetGetActualType(newdev)); + return -1; } =20 virDomainConfNWFilterTeardown(olddev); @@ -3277,12 +3290,16 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, /* all handled in common code directly below this switch */ break; =20 - default: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: virReportError(VIR_ERR_OPERATION_UNSUPPORTED, _("unable to change config on '%s' network type= "), virDomainNetTypeToString(newdev->type)); - break; - + goto cleanup; + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, newdev->type); + goto cleanup; } } else { /* interface type has changed. There are a few special cases @@ -3661,10 +3678,16 @@ qemuDomainChangeGraphics(virQEMUDriverPtr driver, } break; =20 - default: + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to change config on '%s' graphics type"),= type); break; + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsType, dev->type); + break; } =20 cleanup: diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 99d58325cb..2d92d38936 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1468,11 +1468,20 @@ qemuMigrationJobName(virDomainObjPtr vm) =20 switch (priv->job.asyncJob) { case QEMU_ASYNC_JOB_MIGRATION_OUT: - return _("migration job"); + return _("migration out job"); case QEMU_ASYNC_JOB_SAVE: return _("domain save job"); case QEMU_ASYNC_JOB_DUMP: return _("domain core dump job"); + case QEMU_ASYNC_JOB_NONE: + return _("no job"); + case QEMU_ASYNC_JOB_MIGRATION_IN: + return _("migration in job"); + case QEMU_ASYNC_JOB_SNAPSHOT: + return _("snapshot job"); + case QEMU_ASYNC_JOB_START: + return _("start job"); + case QEMU_ASYNC_JOB_LAST: default: return _("job"); } diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 13b05d236a..dc33eb7bcd 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -679,6 +679,8 @@ qemuProcessHandleShutdown(qemuMonitorPtr mon ATTRIBUTE_= UNUSED, detail =3D VIR_DOMAIN_EVENT_SHUTDOWN_HOST; break; =20 + case VIR_TRISTATE_BOOL_ABSENT: + case VIR_TRISTATE_BOOL_LAST: default: detail =3D VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED; break; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146634169829.9720791135892; Tue, 20 Feb 2018 09:10:34 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C3FDE5B2FA; Tue, 20 Feb 2018 17:10:32 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9D8E960C97; Tue, 20 Feb 2018 17:10:32 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 698824A46C; Tue, 20 Feb 2018 17:10:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8YIf009726 for ; Tue, 20 Feb 2018 12:08:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id C96D3AE7B8; Tue, 20 Feb 2018 17:08:34 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5D07BAE7BA; Tue, 20 Feb 2018 17:08:34 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:18 +0000 Message-Id: <20180220170822.16462-11-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 10/14] rpc: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 20 Feb 2018 17:10:33 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/rpc/virnetclient.c | 2 ++ src/rpc/virnetclientprogram.c | 1 + src/rpc/virnetserverprogram.c | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index 8aeacf8774..0c8d58c32c 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -1287,6 +1287,8 @@ virNetClientCallDispatch(virNetClientPtr client) case VIR_NET_STREAM_HOLE: /* Sparse stream protocol*/ return virNetClientCallDispatchStream(client); =20 + case VIR_NET_CALL: + case VIR_NET_CALL_WITH_FDS: default: virReportError(VIR_ERR_RPC, _("got unexpected RPC call prog %d vers %d proc %d = type %d"), diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c index d81a055424..505b40fc4b 100644 --- a/src/rpc/virnetclientprogram.c +++ b/src/rpc/virnetclientprogram.c @@ -384,6 +384,7 @@ int virNetClientProgramCall(virNetClientProgramPtr prog, virNetClientProgramDispatchError(prog, msg); goto error; =20 + case VIR_NET_CONTINUE: default: virReportError(VIR_ERR_RPC, _("Unexpected message status %d"), msg->header.stat= us); diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c index 557651ffbd..75b0052cdb 100644 --- a/src/rpc/virnetserverprogram.c +++ b/src/rpc/virnetserverprogram.c @@ -324,6 +324,10 @@ int virNetServerProgramDispatch(virNetServerProgramPtr= prog, ret =3D 0; break; =20 + case VIR_NET_REPLY: + case VIR_NET_REPLY_WITH_FDS: + case VIR_NET_MESSAGE: + case VIR_NET_STREAM_HOLE: default: virReportError(VIR_ERR_RPC, _("Unexpected message type %u"), --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 151914663690589.34449537578712; Tue, 20 Feb 2018 09:10:36 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BF18D2FA; Tue, 20 Feb 2018 17:10:35 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97D2360486; Tue, 20 Feb 2018 17:10:35 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6495D4A474; Tue, 20 Feb 2018 17:10:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8Z8u009735 for ; Tue, 20 Feb 2018 12:08:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 76A50AE7B6; Tue, 20 Feb 2018 17:08:35 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 09E84AE7BA; Tue, 20 Feb 2018 17:08:34 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:19 +0000 Message-Id: <20180220170822.16462-12-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 11/14] security: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Feb 2018 17:10:36 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/security/security_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/security/security_driver.c b/src/security/security_driver.c index 4800d5255a..a845dc7995 100644 --- a/src/security/security_driver.c +++ b/src/security/security_driver.c @@ -82,6 +82,7 @@ virSecurityDriverPtr virSecurityDriverLookup(const char *= name, } break; =20 + case SECURITY_DRIVER_ERROR: default: return NULL; } --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146566127657.376529299858; Tue, 20 Feb 2018 09:09:26 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3B3BA15565; Tue, 20 Feb 2018 17:09:24 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0B69A5D724; Tue, 20 Feb 2018 17:09:24 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5978F4A477; Tue, 20 Feb 2018 17:09:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8bcC009750 for ; Tue, 20 Feb 2018 12:08:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id D261CAE7BB; Tue, 20 Feb 2018 17:08:37 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 655B6AE7B8; Tue, 20 Feb 2018 17:08:35 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:20 +0000 Message-Id: <20180220170822.16462-13-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 12/14] xen: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Feb 2018 17:09:24 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Ensure all enum cases are listed in switch statements. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- src/vmx/vmx.c | 26 ++++++++++++++++++++++++-- src/xenconfig/xen_common.c | 18 +++++++++++++++--- src/xenconfig/xen_xl.c | 7 ++++++- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 1d13ab03db..3b0c16d5a6 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -3283,11 +3283,19 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXML= OptionPtr xmlopt, virDomainDe =20 break; =20 - default: + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported graphics type '%s'"), virDomainGraphicsTypeToString(def->graphics[i]-= >type)); goto cleanup; + + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsType, def->graphics= [i]->type); + goto cleanup; } } =20 @@ -3782,10 +3790,24 @@ virVMXFormatEthernet(virDomainNetDefPtr def, int co= ntroller, controller); break; =20 - default: + case VIR_DOMAIN_NET_TYPE_ETHERNET: + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_NETWORK: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type= '%s'"), virDomainNetTypeToString(def->type)); return -1; + + case VIR_DOMAIN_NET_TYPE_LAST: + default: + virReportEnumRangeError(virDomainNetType, def->type); + return -1; } =20 /* def:mac -> vmx:addressType, vmx:(generated)Address, vmx:checkMACAdd= ress */ diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index ca3b4dee6a..bc43185363 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -1258,10 +1258,22 @@ xenFormatNet(virConnectPtr conn, } break; =20 + case VIR_DOMAIN_NET_TYPE_VHOSTUSER: + case VIR_DOMAIN_NET_TYPE_SERVER: + case VIR_DOMAIN_NET_TYPE_CLIENT: + case VIR_DOMAIN_NET_TYPE_MCAST: + case VIR_DOMAIN_NET_TYPE_INTERNAL: + case VIR_DOMAIN_NET_TYPE_DIRECT: + case VIR_DOMAIN_NET_TYPE_HOSTDEV: + case VIR_DOMAIN_NET_TYPE_UDP: + case VIR_DOMAIN_NET_TYPE_USER: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported net type= '%s'"), + virDomainNetTypeToString(net->type)); + goto cleanup; + + case VIR_DOMAIN_NET_TYPE_LAST: default: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unsupported network type %d"), - net->type); + virReportEnumRangeError(virDomainNetType, net->type); goto cleanup; } =20 diff --git a/src/xenconfig/xen_xl.c b/src/xenconfig/xen_xl.c index 2ef80eb83a..e1ec8e765f 100644 --- a/src/xenconfig/xen_xl.c +++ b/src/xenconfig/xen_xl.c @@ -1641,8 +1641,13 @@ xenFormatXLSpice(virConfPtr conf, virDomainDefPtr de= f) if (xenConfigSetInt(conf, "spicevdagent", 1) < 0) return -1; break; - default: + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_DEFAULT: break; + case VIR_DOMAIN_GRAPHICS_SPICE_MOUSE_MODE_LAST: + default: + virReportEnumRangeError(virDomainGraphicsSpiceMouseMod= e, + graphics->data.spice.mousemode= ); + return -1; } } =20 --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146568136214.8876013488591; Tue, 20 Feb 2018 09:09:28 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C63F2C036757; Tue, 20 Feb 2018 17:09:26 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86EEB5D723; Tue, 20 Feb 2018 17:09:26 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2C87B18033ED; Tue, 20 Feb 2018 17:09:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8cVZ009758 for ; Tue, 20 Feb 2018 12:08:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 82EFEAE7B8; Tue, 20 Feb 2018 17:08:38 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id 130B8AE7B9; Tue, 20 Feb 2018 17:08:37 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:21 +0000 Message-Id: <20180220170822.16462-14-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 13/14] tools: handle missing switch enum cases 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 20 Feb 2018 17:09:27 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Cast away enum type in places where we don't wish to cover all cases. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- tools/virt-host-validate-qemu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/virt-host-validate-qemu.c b/tools/virt-host-validate-qem= u.c index 2aa396e3ab..d7573ea8b3 100644 --- a/tools/virt-host-validate-qemu.c +++ b/tools/virt-host-validate-qemu.c @@ -33,13 +33,14 @@ int virHostValidateQEMU(void) int ret =3D 0; bool hasHwVirt =3D false; bool hasVirtFlag =3D false; + virArch arch =3D virArchFromHost(); const char *kvmhint =3D _("Check that CPU and firmware supports virtua= lization " "and kvm module is loaded"); =20 if (!(flags =3D virHostValidateGetCPUFlags())) return -1; =20 - switch (virArchFromHost()) { + switch ((int)arch) { case VIR_ARCH_I686: case VIR_ARCH_X86_64: hasVirtFlag =3D true; --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon May 6 03:33:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1519146640222293.60087798281495; Tue, 20 Feb 2018 09:10:40 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C594E2D0FDB; Tue, 20 Feb 2018 17:10:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B0791820F; Tue, 20 Feb 2018 17:10:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6459F180BAE1; Tue, 20 Feb 2018 17:10:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1KH8d6h009775 for ; Tue, 20 Feb 2018 12:08:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 318A3AE7B9; Tue, 20 Feb 2018 17:08:39 +0000 (UTC) Received: from t460.redhat.com (unknown [10.33.36.79]) by smtp.corp.redhat.com (Postfix) with ESMTP id B932EAE7BC; Tue, 20 Feb 2018 17:08:38 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Tue, 20 Feb 2018 17:08:22 +0000 Message-Id: <20180220170822.16462-15-berrange@redhat.com> In-Reply-To: <20180220170822.16462-1-berrange@redhat.com> References: <20180220170822.16462-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 14/14] m4: enforce that all enum cases are listed in switch statements 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: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 20 Feb 2018 17:10:39 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 As a general rule any time we switch() on something that is an enum, we want to have a case for every enum constant. The -Wswitch warning will report any switch where we've violated this rule, except if that switch has a default case. Unfortunately it is reasonable to want to list all enum constants *and* also have a default case. To get a warning in that scenario requires that we turn on -Wswitch-enum. In a few cases where we explicitly don't want to list all enum cases, we can discard the enum type checking by casting the value to a plain int. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: John Ferlan --- m4/virt-compile-warnings.m4 | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 4b35a6f6b5..fc185aef38 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -47,8 +47,6 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ dontwarn=3D"$dontwarn -Wlong-long" # We allow manual list of all enum cases without default: dontwarn=3D"$dontwarn -Wswitch-default" - # We allow optional default: instead of listing all enum values - dontwarn=3D"$dontwarn -Wswitch-enum" # Not a problem since we don't use -fstrict-overflow dontwarn=3D"$dontwarn -Wstrict-overflow" # Not a problem since we don't use -funsafe-loop-optimizations @@ -184,6 +182,11 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # that one off, so we need to manually enable this again wantwarn=3D"$wantwarn -Wjump-misses-init" =20 + # GNULIB explicitly filters it out, preferring -Wswitch + # but that doesn't report missing enums if a default: + # is present. + wantwarn=3D"$wantwarn -Wswitch-enum" + # GNULIB turns on -Wformat=3D2 which implies -Wformat-nonliteral, # so we need to manually re-exclude it. Also, older gcc 4.2 # added an implied ATTRIBUTE_NONNULL on any parameter marked --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list