From nobody Sun Feb 8 06:54:27 2026 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 1518713476110432.6801644751597; Thu, 15 Feb 2018 08:51:16 -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 DDC211752C8; Thu, 15 Feb 2018 16:51:14 +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 8C3164FA44; Thu, 15 Feb 2018 16:51:14 +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 4A8AD4A470; Thu, 15 Feb 2018 16:51:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w1FGhuL2025675 for ; Thu, 15 Feb 2018 11:43:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6AE082026609; Thu, 15 Feb 2018 16:43:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.42.22.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0CB262024CA8; Thu, 15 Feb 2018 16:43:55 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 15 Feb 2018 16:43:13 +0000 Message-Id: <20180215164347.11538-9-berrange@redhat.com> In-Reply-To: <20180215164347.11538-1-berrange@redhat.com> References: <20180215164347.11538-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/42] 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 15 Feb 2018 16:51:15 +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/nwfilter/nwfilter_ebiptables_driver.c | 16 +++++++++++----- src/nwfilter/nwfilter_learnipaddr.c | 6 +++++- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index b8682a1130..c624337f4d 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -320,11 +320,17 @@ _printDataType(virNWFilterVarCombIterPtr vars, VIR_FREE(flags); break; =20 + case DATATYPE_STRING: + case DATATYPE_STRINGCOPY: + case DATATYPE_BOOLEAN: + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Cannot print data type %x"), item->datatype); + return -1; + case DATATYPE_LAST: default: virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unhandled datatype %x"), item->datatype); + _("Unexpected datatype %x"), item->datatype); return -1; - break; } =20 return 0; @@ -1183,7 +1189,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 +1879,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 +2683,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