Since no value in the virGICVersion enumeration is negative, a clever
enough compiler can report an error such as
src/conf/domain_conf.c:15337:75: error: comparison of unsigned enum
expression < 0 is always false [-Werror,-Wtautological-compare]
if ((def->gic_version = virGICVersionTypeFromString(tmp)) < 0 ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
virGICVersionTypeFromString() can, however, return a negative value if
the input string is not part of the enumeration, so we definitely need
that check.
Work around the problem by storing the return value in a temporary int
variable.
---
Pushed under the build-breaker rule.
src/conf/domain_conf.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 295bc1b..0d2957b 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -14728,7 +14728,7 @@ virDomainDefParseXML(xmlDocPtr xml,
xmlNodePtr *nodes = NULL, node = NULL;
char *tmp = NULL;
size_t i, j;
- int n, virtType;
+ int n, virtType, gic_version;
long id = -1;
virDomainDefPtr def;
bool uuid_generated = false;
@@ -15334,12 +15334,13 @@ virDomainDefParseXML(xmlDocPtr xml,
node = ctxt->node;
ctxt->node = nodes[i];
if ((tmp = virXPathString("string(./@version)", ctxt))) {
- if ((def->gic_version = virGICVersionTypeFromString(tmp)) < 0 ||
- def->gic_version == VIR_GIC_VERSION_NONE) {
+ gic_version = virGICVersionTypeFromString(tmp);
+ if (gic_version < 0 || gic_version == VIR_GIC_VERSION_NONE) {
virReportError(VIR_ERR_XML_ERROR,
_("malformed gic version: %s"), tmp);
goto error;
}
+ def->gic_version = gic_version;
VIR_FREE(tmp);
}
def->features[val] = VIR_TRISTATE_SWITCH_ON;
--
2.5.0