提交 9275def5 编写于 作者: D Daniel P. Berrangé

util: handle missing switch enum cases

Ensure all enum cases are listed in switch statements.
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
上级 3b1020ac
...@@ -296,7 +296,9 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val) ...@@ -296,7 +296,9 @@ virConfSaveValue(virBufferPtr buf, virConfValuePtr val)
virBufferAddLit(buf, " ]"); virBufferAddLit(buf, " ]");
break; break;
} }
case VIR_CONF_LAST:
default: default:
virReportEnumRangeError(virConfType, val->type);
return -1; return -1;
} }
return 0; return 0;
...@@ -986,13 +988,20 @@ int virConfGetValueStringList(virConfPtr conf, ...@@ -986,13 +988,20 @@ int virConfGetValueStringList(virConfPtr conf,
} }
ATTRIBUTE_FALLTHROUGH; ATTRIBUTE_FALLTHROUGH;
default: case VIR_CONF_LLONG:
case VIR_CONF_ULLONG:
case VIR_CONF_NONE:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
compatString ? compatString ?
_("%s: expected a string or string list for '%s' parameter") : _("%s: expected a string or string list for '%s' parameter") :
_("%s: expected a string list for '%s' parameter"), _("%s: expected a string list for '%s' parameter"),
conf->filename, setting); conf->filename, setting);
return -1; return -1;
case VIR_CONF_LAST:
default:
virReportEnumRangeError(virConfType, cval->type);
return -1;
} }
return 1; return 1;
......
...@@ -173,7 +173,7 @@ void virReportSystemErrorFull(int domcode, ...@@ -173,7 +173,7 @@ void virReportSystemErrorFull(int domcode,
virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, \ virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, \
__FILE__, __FUNCTION__, __LINE__, \ __FILE__, __FUNCTION__, __LINE__, \
"Unexpected enum value %d for %s", \ "Unexpected enum value %d for %s", \
value, sizeof((typename)1) != 0 ? #typname : #typname); value, sizeof((typname)1) != 0 ? #typname : #typname);
void virReportOOMErrorFull(int domcode, void virReportOOMErrorFull(int domcode,
const char *filename, const char *filename,
......
...@@ -827,9 +827,11 @@ virFirewallApplyRule(virFirewallPtr firewall, ...@@ -827,9 +827,11 @@ virFirewallApplyRule(virFirewallPtr firewall,
if (virFirewallApplyRuleFirewallD(rule, ignoreErrors, &output) < 0) if (virFirewallApplyRuleFirewallD(rule, ignoreErrors, &output) < 0)
return -1; return -1;
break; break;
case VIR_FIREWALL_BACKEND_AUTOMATIC:
case VIR_FIREWALL_BACKEND_LAST:
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportEnumRangeError(virFirewallBackend, currentBackend);
_("Unexpected firewall engine backend"));
return -1; return -1;
} }
......
...@@ -1206,20 +1206,30 @@ virLogGetOutputs(void) ...@@ -1206,20 +1206,30 @@ virLogGetOutputs(void)
virLogDestinationTypeToString(dest), virLogDestinationTypeToString(dest),
virLogOutputs[i]->name); virLogOutputs[i]->name);
break; break;
default: case VIR_LOG_TO_STDERR:
case VIR_LOG_TO_JOURNALD:
virBufferAsprintf(&outputbuf, "%d:%s", virBufferAsprintf(&outputbuf, "%d:%s",
virLogOutputs[i]->priority, virLogOutputs[i]->priority,
virLogDestinationTypeToString(dest)); virLogDestinationTypeToString(dest));
break;
case VIR_LOG_TO_OUTPUT_LAST:
default:
virReportEnumRangeError(virLogDestination, dest);
goto error;
} }
} }
virLogUnlock();
if (virBufferError(&outputbuf)) { if (virBufferError(&outputbuf)) {
virBufferFreeAndReset(&outputbuf); goto error;
return NULL;
} }
virLogUnlock();
return virBufferContentAndReset(&outputbuf); return virBufferContentAndReset(&outputbuf);
error:
virLogUnlock();
virBufferFreeAndReset(&outputbuf);
return NULL;
} }
......
...@@ -1071,6 +1071,9 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname, ...@@ -1071,6 +1071,9 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname,
case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE: case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE:
op = PORT_REQUEST_PREASSOCIATE; op = PORT_REQUEST_PREASSOCIATE;
break; break;
case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE_RR:
op = PORT_REQUEST_PREASSOCIATE_RR;
break;
case VIR_NETDEV_VPORT_PROFILE_LINK_OP_ASSOCIATE: case VIR_NETDEV_VPORT_PROFILE_LINK_OP_ASSOCIATE:
op = PORT_REQUEST_ASSOCIATE; op = PORT_REQUEST_ASSOCIATE;
break; break;
...@@ -1191,10 +1194,15 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname, ...@@ -1191,10 +1194,15 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname,
false); false);
break; break;
default: case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("operation type %d not supported"), virtPortOp); _("operation type %d not supported"), virtPortOp);
rc = -1; rc = -1;
break;
default:
virReportEnumRangeError(virNetDevVPortProfileType, virtPortOp);
rc = -1;
break;
} }
cleanup: cleanup:
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40 # define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
enum virNetDevVPortProfile { typedef enum virNetDevVPortProfile {
VIR_NETDEV_VPORT_PROFILE_NONE, VIR_NETDEV_VPORT_PROFILE_NONE,
VIR_NETDEV_VPORT_PROFILE_8021QBG, VIR_NETDEV_VPORT_PROFILE_8021QBG,
VIR_NETDEV_VPORT_PROFILE_8021QBH, VIR_NETDEV_VPORT_PROFILE_8021QBH,
...@@ -38,7 +38,7 @@ enum virNetDevVPortProfile { ...@@ -38,7 +38,7 @@ enum virNetDevVPortProfile {
VIR_NETDEV_VPORT_PROFILE_MIDONET, VIR_NETDEV_VPORT_PROFILE_MIDONET,
VIR_NETDEV_VPORT_PROFILE_LAST, VIR_NETDEV_VPORT_PROFILE_LAST,
}; } virNetDevVPortProfileType;
VIR_ENUM_DECL(virNetDevVPort) VIR_ENUM_DECL(virNetDevVPort)
typedef enum { typedef enum {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册