From: Peter Krempa Date: Thu, 19 Nov 2020 09:44:12 +0000 (+0100) Subject: virsh: cmdAttachDisk: Refactor control flow X-Git-Tag: v6.10.0-rc1~68 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=426369ebfad84ae83ac37adcf36e4890569143af;p=thirdparty%2Flibvirt.git virsh: cmdAttachDisk: Refactor control flow Remove the unnecessary 'cleanup:' label since we can directly return as the memory clearing is now automated. We can also remove the 'functionReturn' variable and use the usual pattern of returning success. Signed-off-by: Peter Krempa Reviewed-by: Daniel Henrique Barboza --- diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 42a255cd6d..2eaac9ad8c 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -578,7 +578,6 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) const char *alias = NULL; struct DiskAddress diskAddr; bool isFile = false; - bool functionReturn = false; int ret; unsigned int flags = VIR_DOMAIN_AFFECT_CURRENT; const char *stype = NULL; @@ -615,7 +614,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) vshCommandOptStringReq(ctl, cmd, "targetbus", &targetbus) < 0 || vshCommandOptStringReq(ctl, cmd, "alias", &alias) < 0 || vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0) - goto cleanup; + return false; if (!stype) { if (driver && (STREQ(driver, "file") || STREQ(driver, "tap"))) { @@ -628,19 +627,19 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd) isFile = true; } else if (STRNEQ(stype, "block")) { vshError(ctl, _("Unknown source type: '%s'"), stype); - goto cleanup; + return false; } if (mode) { if (STRNEQ(mode, "readonly") && STRNEQ(mode, "shareable")) { vshError(ctl, _("No support for %s in command 'attach-disk'"), mode); - goto cleanup; + return false; } } if (wwn && !virValidateWWN(wwn)) - goto cleanup; + return false; /* Make XML of disk */ virBufferAsprintf(&buf, "