diff --git a/src/util/virconf.c b/src/util/virconf.c index a82a509ca31070eb3002e7b29a024c8707806bca..e0a3fd12c04f9df0ae2a3a7054292f1093ab8693 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; - 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' parameter") : _("%s: expected a string list for '%s' parameter"), conf->filename, setting); return -1; + + case VIR_CONF_LAST: + default: + virReportEnumRangeError(virConfType, cval->type); + return -1; } return 1; diff --git a/src/util/virerror.h b/src/util/virerror.h index f0df8f24de628977f780cb9cb244f80b256a5967..760bfa43df07490a5091486348a7f70e7a5c1e5c 100644 --- a/src/util/virerror.h +++ b/src/util/virerror.h @@ -173,7 +173,7 @@ void virReportSystemErrorFull(int domcode, virReportErrorHelper(VIR_FROM_THIS, VIR_ERR_INTERNAL_ERROR, \ __FILE__, __FUNCTION__, __LINE__, \ "Unexpected enum value %d for %s", \ - value, sizeof((typename)1) != 0 ? #typname : #typname); + value, sizeof((typname)1) != 0 ? #typname : #typname); void virReportOOMErrorFull(int domcode, const char *filename, diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index ff1bb83073742a6f6ef0c2c4cc6ab780d6b4ae9e..10c370a2aec0883177e92334cb8dd6db911c8dd7 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; } diff --git a/src/util/virlog.c b/src/util/virlog.c index 4f66cc5e5cd9ff0bf531192381db8df9fe7aea07..c03f4fb14e5544fa9e28958f9e2c1c24b001c0bd 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -1206,20 +1206,30 @@ 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); + goto error; } } - virLogUnlock(); if (virBufferError(&outputbuf)) { - virBufferFreeAndReset(&outputbuf); - return NULL; + goto error; } + virLogUnlock(); return virBufferContentAndReset(&outputbuf); + + error: + virLogUnlock(); + virBufferFreeAndReset(&outputbuf); + return NULL; } diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c index db495a7549eab21fb12080a9306878a6f85dea53..133d962db6b274a85f18f41158c33395d9d6d416 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 = PORT_REQUEST_PREASSOCIATE; break; + case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE_RR: + op = PORT_REQUEST_PREASSOCIATE_RR; + break; case VIR_NETDEV_VPORT_PROFILE_LINK_OP_ASSOCIATE: op = PORT_REQUEST_ASSOCIATE; break; @@ -1191,10 +1194,15 @@ virNetDevVPortProfileOp8021Qbh(const char *ifname, false); break; - default: + case VIR_NETDEV_VPORT_PROFILE_LINK_OP_PREASSOCIATE: virReportError(VIR_ERR_INTERNAL_ERROR, _("operation type %d not supported"), virtPortOp); rc = -1; + break; + default: + virReportEnumRangeError(virNetDevVPortProfileType, virtPortOp); + rc = -1; + break; } cleanup: diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h index b706c411934ef55995c77a7e6066bb887a75008c..fdb6573fd46a108ae543a50196974b9de4057924 100644 --- a/src/util/virnetdevvportprofile.h +++ b/src/util/virnetdevvportprofile.h @@ -30,7 +30,7 @@ # define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40 -enum virNetDevVPortProfile { +typedef enum virNetDevVPortProfile { VIR_NETDEV_VPORT_PROFILE_NONE, VIR_NETDEV_VPORT_PROFILE_8021QBG, VIR_NETDEV_VPORT_PROFILE_8021QBH, @@ -38,7 +38,7 @@ enum virNetDevVPortProfile { VIR_NETDEV_VPORT_PROFILE_MIDONET, VIR_NETDEV_VPORT_PROFILE_LAST, -}; +} virNetDevVPortProfileType; VIR_ENUM_DECL(virNetDevVPort) typedef enum {