Instead of goto cleanup lable, it will work fine if go to cleanup lable, but it's somewhat waste. And some functions don't check if the "domain == NULL" before trying to free it with virDomainFree(dom), as a result, there is additional error in the log says: error: invalid domain pointer in virDomainFree Which is useless. --- tools/virsh.c | 60 ++++++++++++++++++++++++++++---------------------------- 1 files changed, 30 insertions(+), 30 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 7d849ec..ffb4ced 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -5201,10 +5201,10 @@ blockJobImpl(vshControl *ctl, const vshCmd *cmd, int ret = -1; if (!vshConnectionUsability(ctl, ctl->conn)) - goto out; + return -1; if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) - goto out; + return -1; if (vshCommandOptString(cmd, "path", &path) < 0) goto out; @@ -10519,10 +10519,10 @@ cmdAttachInterface(vshControl *ctl, const vshCmd *cmd) char *xml; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; if (vshCommandOptString(cmd, "type", &type) <= 0) goto cleanup; @@ -10633,10 +10633,10 @@ cmdDetachInterface(vshControl *ctl, const vshCmd *cmd) unsigned int flags; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; if (vshCommandOptString(cmd, "type", &type) <= 0) goto cleanup; @@ -10922,10 +10922,10 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) char *xml; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; if (vshCommandOptString(cmd, "source", &source) <= 0) goto cleanup; @@ -11105,10 +11105,10 @@ cmdDetachDisk(vshControl *ctl, const vshCmd *cmd) unsigned int flags; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) - goto cleanup; + return false; if (vshCommandOptString(cmd, "target", &target) <= 0) goto cleanup; @@ -11655,11 +11655,11 @@ cmdEdit (vshControl *ctl, const vshCmd *cmd) int flags = VIR_DOMAIN_XML_SECURE | VIR_DOMAIN_XML_INACTIVE; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain (ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; /* Get the XML configuration of the domain. */ doc = virDomainGetXMLDesc (dom, flags); @@ -11806,11 +11806,11 @@ cmdSnapshotCreate(vshControl *ctl, const vshCmd *cmd) char *name = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "xmlfile", &from) <= 0) buffer = vshStrdup(ctl, "<domainsnapshot/>"); @@ -11902,11 +11902,11 @@ cmdSnapshotCreateAs(vshControl *ctl, const vshCmd *cmd) virBuffer buf = VIR_BUFFER_INITIALIZER; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "name", &name) < 0 || vshCommandOptString(cmd, "description", &desc) < 0) { @@ -11995,11 +11995,11 @@ cmdSnapshotCurrent(vshControl *ctl, const vshCmd *cmd) char *xml = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; current = virDomainHasCurrentSnapshot(dom, 0); if (current < 0) @@ -12079,11 +12079,11 @@ cmdSnapshotList(vshControl *ctl, const vshCmd *cmd) struct tm time_info; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; numsnaps = virDomainSnapshotNum(dom, 0); @@ -12186,11 +12186,11 @@ cmdSnapshotDumpXML(vshControl *ctl, const vshCmd *cmd) char *xml = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "snapshotname", &name) <= 0) goto cleanup; @@ -12245,11 +12245,11 @@ cmdSnapshotParent(vshControl *ctl, const vshCmd *cmd) xmlXPathContextPtr ctxt = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "snapshotname", &name) <= 0) goto cleanup; @@ -12311,11 +12311,11 @@ cmdDomainSnapshotRevert(vshControl *ctl, const vshCmd *cmd) virDomainSnapshotPtr snapshot = NULL; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "snapshotname", &name) <= 0) goto cleanup; @@ -12364,11 +12364,11 @@ cmdSnapshotDelete(vshControl *ctl, const vshCmd *cmd) unsigned int flags = 0; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; if (vshCommandOptString(cmd, "snapshotname", &name) <= 0) goto cleanup; @@ -12427,11 +12427,11 @@ cmdQemuMonitorCommand(vshControl *ctl, const vshCmd *cmd) bool pad = false; if (!vshConnectionUsability(ctl, ctl->conn)) - goto cleanup; + return false; dom = vshCommandOptDomain(ctl, cmd, NULL); if (dom == NULL) - goto cleanup; + return false; while ((opt = vshCommandOptArgv(cmd, opt))) { if (pad) -- 1.7.6 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list