On Wed, Sep 23, 2020 at 08:14:52PM +0200, Ján Tomko wrote:
Use goto to jump over the ret = 0 assignment as is usual in rest of the code. Signed-off-by: Ján Tomko <jtomko@xxxxxxxxxx> --- 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 9978741a64..99c7fbd117 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;
This one is not semantically equivalent. But since I do not know enough about the vbox driver I cannot tell whether it makes sense to keep the current behaviour. It looks like it also fixes it but I cannot be sure enough. Let's wait for a couple of days if someone knows more about that and if not, then consider this Reviewed-by: Martin Kletzander <mkletzan@xxxxxxxxxx> and let's see if someone experiences issues after that.
} 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); -- 2.26.2
Attachment:
signature.asc
Description: PGP signature