From: Ján Tomko Date: Thu, 5 Jun 2014 08:42:19 +0000 (+0200) Subject: virsh: Invert logic in cmdVcpuinfo X-Git-Tag: v1.2.6-rc1~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bec105e6db3efba02374f868c8454d7203cdc9f8;p=thirdparty%2Flibvirt.git virsh: Invert logic in cmdVcpuinfo Initialize 'ret' to false and introduce a cleanup label. --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 84a6706e6c..4d21704ba6 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -5536,25 +5536,21 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) { virDomainInfo info; virDomainPtr dom; - virVcpuInfoPtr cpuinfo; - unsigned char *cpumaps; + virVcpuInfoPtr cpuinfo = NULL; + unsigned char *cpumaps = NULL; int ncpus, maxcpu; size_t cpumaplen; - bool ret = true; + bool ret = false; int n, m; if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) return false; - if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) { - virDomainFree(dom); - return false; - } + if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) + goto cleanup; - if (virDomainGetInfo(dom, &info) != 0) { - virDomainFree(dom); - return false; - } + if (virDomainGetInfo(dom, &info) != 0) + goto cleanup; cpuinfo = vshMalloc(ctl, sizeof(virVcpuInfo)*info.nrVirtCpu); cpumaplen = VIR_CPU_MAPLEN(maxcpu); @@ -5608,10 +5604,13 @@ cmdVcpuinfo(vshControl *ctl, const vshCmd *cmd) } } } else { - ret = false; + goto cleanup; } } + ret = true; + + cleanup: VIR_FREE(cpumaps); VIR_FREE(cpuinfo); virDomainFree(dom);