1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-03-20 07:59:00 +00:00

virsh-snapshot: Fix coding style and remove dead code

buffer won't be NULL in any case when reaching the check and the first
block of the if statement was lacking parentheses
This commit is contained in:
Peter Krempa 2013-01-21 17:48:26 +01:00
parent e7aa207cd7
commit f4464002fc

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