From cda1cc170f07b45911b3dad03e42c8ebfc210fa1 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Tue, 16 Feb 2016 17:41:47 +0100 Subject: [PATCH] conf: Use a temporary int variable to store GIC version 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. --- 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 295bc1bcaf..0d2957b69c 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;