mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
nwfilter: handle missing switch enum cases
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. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
017dfa27dd
commit
d4bf8f4150
@ -86,7 +86,7 @@ typedef enum {
|
||||
(((data)->flags) & NWFILTER_ENTRY_ITEM_FLAG_IS_NEG)
|
||||
|
||||
/* datatypes appearing in rule attributes */
|
||||
enum attrDatatype {
|
||||
typedef enum attrDatatype {
|
||||
DATATYPE_UINT16 = (1 << 0),
|
||||
DATATYPE_UINT8 = (1 << 1),
|
||||
DATATYPE_UINT16_HEX = (1 << 2),
|
||||
@ -106,7 +106,7 @@ enum attrDatatype {
|
||||
DATATYPE_IPSETFLAGS = (1 << 16),
|
||||
|
||||
DATATYPE_LAST = (1 << 17),
|
||||
};
|
||||
} virNWFilterAttrDataType;
|
||||
|
||||
# define NWFILTER_MAC_BGA "01:80:c2:00:00:00"
|
||||
|
||||
|
@ -320,11 +320,16 @@ _printDataType(virNWFilterVarCombIterPtr vars,
|
||||
VIR_FREE(flags);
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1183,7 +1188,7 @@ _iptablesCreateRuleInstance(virFirewallPtr fw,
|
||||
|
||||
PRINT_IPT_ROOT_CHAIN(chain, chainPrefix, ifname);
|
||||
|
||||
switch (rule->prtclType) {
|
||||
switch ((int)rule->prtclType) {
|
||||
case VIR_NWFILTER_RULE_PROTOCOL_TCP:
|
||||
case VIR_NWFILTER_RULE_PROTOCOL_TCPoIPV6:
|
||||
fwrule = 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, "/")
|
||||
|
||||
switch (rule->prtclType) {
|
||||
switch ((int)rule->prtclType) {
|
||||
case VIR_NWFILTER_RULE_PROTOCOL_MAC:
|
||||
fwrule = virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET,
|
||||
"-t", "nat",
|
||||
@ -2677,7 +2682,7 @@ ebtablesCreateTmpSubChainFW(virFirewallPtr fw,
|
||||
fwrule = virFirewallAddRule(fw, VIR_FIREWALL_LAYER_ETHERNET,
|
||||
"-t", "nat", "-A", rootchain, NULL);
|
||||
|
||||
switch (protoidx) {
|
||||
switch ((int)protoidx) {
|
||||
case L2_PROTO_MAC_IDX:
|
||||
break;
|
||||
case L2_PROTO_STP_IDX:
|
||||
|
@ -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 = 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 = EINVAL;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (virBufferError(&buf)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user