]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nodedev: fix build with clang
authorRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 18 Feb 2017 11:46:28 +0000 (15:46 +0400)
committerRoman Bogorodskiy <bogorodskiy@gmail.com>
Sat, 18 Feb 2017 13:49:27 +0000 (17:49 +0400)
Build fails with:

conf/node_device_conf.c:825:62: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
    if ((data->drm.type = virNodeDevDRMTypeFromString(type)) < 0) {
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
conf/node_device_conf.c:1801:59: error: comparison of unsigned enum expression < 0 is always false [-Werror,-Wtautological-compare]
        if ((type = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~
2 errors generated.

Fix by using intermediate variable to store the result similarly
to how it's done for other FromString* calls.

src/conf/node_device_conf.c

index b3063d9ec0144e50042ad6da35c1b1e9341bc27c..c15c917a24c99f4c76c1408b0776f25c8e901732 100644 (file)
@@ -814,7 +814,7 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt,
                          virNodeDevCapDataPtr data)
 {
     xmlNodePtr orignode;
-    int ret = -1;
+    int ret = -1, val;
     char *type = NULL;
 
     orignode = ctxt->node;
@@ -822,11 +822,12 @@ virNodeDevCapDRMParseXML(xmlXPathContextPtr ctxt,
 
     type = virXPathString("string(./type[1])", ctxt);
 
-    if ((data->drm.type = virNodeDevDRMTypeFromString(type)) < 0) {
+    if ((val = virNodeDevDRMTypeFromString(type)) < 0) {
         virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                        _("unknown drm type '%s' for '%s'"), type, def->name);
         goto out;
     }
+    data->drm.type = val;
 
     ret = 0;
 
@@ -1791,6 +1792,7 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
         xmlNodePtr node = nodes[i];
         char *tmp = virXMLPropString(node, "type");
         virNodeDevDevnodeType type;
+        int val;
 
         if (!tmp) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
@@ -1798,12 +1800,13 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt,
             goto error;
         }
 
-        if ((type = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
+        if ((val = virNodeDevDevnodeTypeFromString(tmp)) < 0) {
             virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
                            _("unknown devnode type '%s'"), tmp);
             VIR_FREE(tmp);
             goto error;
         }
+        type = val;
 
         switch (type) {
         case VIR_NODE_DEV_DEVNODE_DEV: