From 3013c4659d466a60a5c674ee17aec6f9e17d25a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Wed, 23 Sep 2020 18:35:41 +0200 Subject: [PATCH] vbox: StartMachine: overwrite ret less often MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use goto to jump over the ret = 0 assignment as is usual in rest of the code. Signed-off-by: Ján Tomko Reviewed-by: Martin Kletzander --- src/vbox/vbox_common.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index ffe03061a1..9f6ef2f2ac 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -2090,7 +2090,7 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid int ret = -1; if (!data->vboxObj) - return ret; + return -1; VBOX_UTF8_TO_UTF16("FRONTEND/Type", &keyTypeUtf16); gVBoxAPI.UIMachine.GetExtraData(machine, keyTypeUtf16, &valueTypeUtf16); @@ -2177,7 +2177,7 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid if (NS_FAILED(rc)) { virReportError(VIR_ERR_OPERATION_FAILED, "%s", _("OpenRemoteSession/LaunchVMProcess failed, domain can't be started")); - ret = -1; + goto cleanup; } else { PRBool completed = 0; resultCodeUnion resultCode; @@ -2186,19 +2186,21 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid rc = gVBoxAPI.UIProgress.GetCompleted(progress, &completed); if (NS_FAILED(rc)) { /* error */ - ret = -1; + goto cleanup; } gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); if (RC_FAILED(resultCode)) { /* error */ - ret = -1; + goto cleanup; } else { /* all ok set the domid */ dom->id = maxDomID + 1; - ret = 0; } } + ret = 0; + + cleanup: VBOX_RELEASE(progress); gVBoxAPI.UISession.Close(data->vboxSession);