]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh-nodedev: Avoid spurious errors
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 2 Jun 2014 14:48:22 +0000 (16:48 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 2 Jun 2014 16:09:09 +0000 (18:09 +0200)
Our public free functions explicitly don't accept NULL pointers
(sigh). Therefore, callers must do something like this:

    if (dev)
        virNodeDeviceFree(dev);

And we are not doing that on two places I've found. This leads to
dummy error message thrown by virsh:

    virsh # nodedev-dumpxml nonexistent-device
    error: Could not find matching device 'nonexistent-device'
    error: invalid node device pointer in virNodeDeviceFree

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-nodedev.c

index a35387a3ba7ff0a32229e1e32621c0af8b6a37fa..46e0045270a443ff3286dea80d1bd8986eb07ba7 100644 (file)
@@ -162,7 +162,8 @@ cmdNodeDeviceDestroy(vshControl *ctl, const vshCmd *cmd)
     ret = true;
  cleanup:
     virStringFreeList(arr);
-    virNodeDeviceFree(dev);
+    if (dev)
+        virNodeDeviceFree(dev);
     return ret;
 }
 
@@ -571,7 +572,8 @@ cmdNodeDeviceDumpXML(vshControl *ctl, const vshCmd *cmd)
  cleanup:
     virStringFreeList(arr);
     VIR_FREE(xml);
-    virNodeDeviceFree(device);
+    if (device)
+        virNodeDeviceFree(device);
     return ret;
 }