]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf: Use a temporary int variable to store GIC version osstest/frozen/xen-4.5-testing
authorAndrea Bolognani <abologna@redhat.com>
Tue, 16 Feb 2016 16:41:47 +0000 (17:41 +0100)
committerAndrea Bolognani <abologna@redhat.com>
Tue, 16 Feb 2016 17:12:17 +0000 (18:12 +0100)
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

index 295bc1bcafb949a513b6fbb6f4c2631fe2b02934..0d2957b69c5f147d90ec55e7f381bdc248b544dc 100644 (file)
@@ -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;