]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
virsh-snapshot: Fix coding style and remove dead code
authorPeter Krempa <pkrempa@redhat.com>
Mon, 21 Jan 2013 16:48:26 +0000 (17:48 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Mon, 4 Feb 2013 09:34:33 +0000 (10:34 +0100)
buffer won't be NULL in any case when reaching the check and the first
block of the if statement was lacking parentheses

tools/virsh-snapshot.c

index e4745d656c7ea50c0d926caa8f1b04a481e0d25b..f76c40e342911c70fbc820234817a5797f231dae 100644 (file)
@@ -204,26 +204,17 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd)
     if (vshCommandOptBool(cmd, "live"))
         flags |= VIR_DOMAIN_SNAPSHOT_CREATE_LIVE;
 
-    dom = vshCommandOptDomain(ctl, cmd, NULL);
-    if (dom == NULL)
+    if (!(dom = vshCommandOptDomain(ctl, cmd, NULL)))
         goto cleanup;
 
-    if (vshCommandOptString(cmd, "xmlfile", &from) <= 0)
+    if (vshCommandOptString(cmd, "xmlfile", &from) <= 0) {
         buffer = vshStrdup(ctl, "<domainsnapshot/>");
-    else {
+    else {
         if (virFileReadAll(from, VSH_MAX_XML_FILE, &buffer) < 0) {
-            /* we have to report the error here because during cleanup
-             * we'll run through virDomainFree(), which loses the
-             * last error
-             */
-            vshReportError(ctl);
+            vshSaveLibvirtError();
             goto cleanup;
         }
     }
-    if (buffer == NULL) {
-        vshError(ctl, "%s", _("Out of memory"));
-        goto cleanup;
-    }
 
     ret = vshSnapshotCreate(ctl, dom, buffer, flags, from);