]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu: Resolve Coverity FORWARD_NULL
authorJohn Ferlan <jferlan@redhat.com>
Tue, 5 May 2015 10:59:56 +0000 (06:59 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 6 May 2015 00:02:37 +0000 (20:02 -0400)
Coverity complains over the [n]values pairing in virQEMUCapsFreeStringList
and rather than make a bunch if "if values" checks prior to calling, by
just adding the values check inside the free function we avoid the chance
that somehow nvalues is > 0, while values == NULL

src/qemu/qemu_capabilities.c

index d50863ff969df89970502b5826c5e67edc0baec4..25c15bfc816a0a046e140ef84ea947e2c42ab397 100644 (file)
@@ -1702,6 +1702,8 @@ virQEMUCapsFreeStringList(size_t len,
                           char **values)
 {
     size_t i;
+    if (!values)
+        return;
     for (i = 0; i < len; i++)
         VIR_FREE(values[i]);
     VIR_FREE(values);
@@ -1794,7 +1796,7 @@ virQEMUCapsParseDeviceStrObjectProps(const char *str,
     ret = nproplist;
 
  cleanup:
-    if (ret < 0 && proplist)
+    if (ret < 0)
         virQEMUCapsFreeStringList(nproplist, proplist);
     return ret;
 }