On 2013年01月22日 02:07, Peter Krempa wrote:
This patch simplifies error paths and switches to use vshCommandOptStringReq for argument retrieval in cmdSnapshotDumpXML --- tools/virsh-snapshot.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tools/virsh-snapshot.c b/tools/virsh-snapshot.c index f76c40e..c980b5b 100644 --- a/tools/virsh-snapshot.c +++ b/tools/virsh-snapshot.c @@ -1775,31 +1775,26 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptBool(cmd, "security-info")) flags |= VIR_DOMAIN_XML_SECURE; - dom = vshCommandOptDomain(ctl, cmd, NULL); - if (dom == NULL) - goto cleanup; + if (vshCommandOptStringReq(ctl, cmd, "snapshotname",&name)< 0) + return false; - if (vshCommandOptString(cmd, "snapshotname",&name)<= 0) - goto cleanup; + if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) + return false; - snapshot = virDomainSnapshotLookupByName(dom, name, 0); - if (snapshot == NULL) + if (!(snapshot = virDomainSnapshotLookupByName(dom, name, 0))) goto cleanup; - xml = virDomainSnapshotGetXMLDesc(snapshot, flags); - if (!xml) + if (!(xml = virDomainSnapshotGetXMLDesc(snapshot, flags))) goto cleanup; vshPrint(ctl, "%s", xml); - ret = true; cleanup: VIR_FREE(xml); if (snapshot) virDomainSnapshotFree(snapshot); - if (dom) - virDomainFree(dom); + virDomainFree(dom); return ret; }
ACK -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list