VirtualBox

Ignore:
Timestamp:
May 31, 2022 9:11:39 AM (3 years ago)
Author:
vboxsync
Message:

Frontends + Main: Adjust to the new rules wrt. to rc -> hrc,vrc usage. This also fixes quite a few bugs wrt shadow variables, wrong return values and output error translations / exit codes. Also see @todos added. ​​bugref:10223

Location:
trunk/src/VBox/Frontends/VBoxAutostart
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartStart.cpp

    r95139 r95140  
    8787     */
    8888    com::SafeIfaceArray<IMachine> machines;
    89     HRESULT rc = g_pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
    90     if (SUCCEEDED(rc))
     89    HRESULT hrc = g_pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
     90    if (SUCCEEDED(hrc))
    9191    {
    9292        /*
     
    131131         * just to add this log, hence a bit of duplicate logic here.
    132132         */
    133         if (SUCCEEDED(rc))
     133        if (SUCCEEDED(hrc))
    134134        {
    135135            if (machines.size() == 0)
     
    142142        }
    143143        else
    144             autostartSvcLogError("Enumerating virtual machines failed with %Rhrc\n", rc);
    145 
    146         if (   SUCCEEDED(rc)
     144            autostartSvcLogError("Enumerating virtual machines failed with %Rhrc\n", hrc);
     145
     146        if (   SUCCEEDED(hrc)
    147147            && !listVM.empty())
    148148        {
     
    173173                CHECK_ERROR_BREAK(machine, LaunchVMProcess(g_pSession, Bstr("headless").raw(),
    174174                                                           ComSafeArrayNullInParam(), progress.asOutParam()));
    175                 if (SUCCEEDED(rc) && !progress.isNull())
     175                if (SUCCEEDED(hrc) && !progress.isNull())
    176176                {
    177177                    autostartSvcLogVerbose(1, "Waiting for machine '%ls' to power on ...\n", strName.raw());
    178178                    CHECK_ERROR(progress, WaitForCompletion(-1));
    179                     if (SUCCEEDED(rc))
     179                    if (SUCCEEDED(hrc))
    180180                    {
    181181                        BOOL completed = true;
    182182                        CHECK_ERROR(progress, COMGETTER(Completed)(&completed));
    183                         if (SUCCEEDED(rc))
     183                        if (SUCCEEDED(hrc))
    184184                        {
    185185                            ASSERT(completed);
     
    187187                            LONG iRc;
    188188                            CHECK_ERROR(progress, COMGETTER(ResultCode)(&iRc));
    189                             if (SUCCEEDED(rc))
     189                            if (SUCCEEDED(hrc))
    190190                            {
    191191                                if (FAILED(iRc))
     
    202202                SessionState_T enmSessionState;
    203203                CHECK_ERROR(g_pSession, COMGETTER(State)(&enmSessionState));
    204                 if (SUCCEEDED(rc) && enmSessionState == SessionState_Locked)
     204                if (SUCCEEDED(hrc) && enmSessionState == SessionState_Locked)
    205205                    g_pSession->UnlockMachine();
    206206            }
  • trunk/src/VBox/Frontends/VBoxAutostart/VBoxAutostartStop.cpp

    r95139 r95140  
    4949static HRESULT autostartSaveVMState(ComPtr<IConsole> &console)
    5050{
    51     HRESULT rc = S_OK;
     51    HRESULT hrc = S_OK;
    5252    ComPtr<IMachine> machine;
    5353    ComPtr<IProgress> progress;
     
    5757        /* first pause so we don't trigger a live save which needs more time/resources */
    5858        bool fPaused = false;
    59         rc = console->Pause();
    60         if (FAILED(rc))
     59        hrc = console->Pause();
     60        if (FAILED(hrc))
    6161        {
    6262            bool fError = true;
    63             if (rc == VBOX_E_INVALID_VM_STATE)
     63            if (hrc == VBOX_E_INVALID_VM_STATE)
    6464            {
    6565                /* check if we are already paused */
     
    6767                CHECK_ERROR_BREAK(console, COMGETTER(State)(&machineState));
    6868                /* the error code was lost by the previous instruction */
    69                 rc = VBOX_E_INVALID_VM_STATE;
     69                hrc = VBOX_E_INVALID_VM_STATE;
    7070                if (machineState != MachineState_Paused)
    7171                {
     
    8585        CHECK_ERROR(console, COMGETTER(Machine)(machine.asOutParam()));
    8686        CHECK_ERROR(machine, SaveState(progress.asOutParam()));
    87         if (FAILED(rc))
     87        if (FAILED(hrc))
    8888        {
    8989            if (!fPaused)
     
    9292        }
    9393
    94         rc = showProgress(progress);
     94        hrc = showProgress(progress);
    9595        CHECK_PROGRESS_ERROR(progress, ("Failed to save machine state"));
    96         if (FAILED(rc))
     96        if (FAILED(hrc))
    9797        {
    9898            if (!fPaused)
     
    101101    } while (0);
    102102
    103     return rc;
     103    return hrc;
    104104}
    105105
     
    116116     */
    117117    com::SafeIfaceArray<IMachine> machines;
    118     HRESULT rc = g_pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
    119     if (SUCCEEDED(rc))
     118    HRESULT hrc = g_pVirtualBox->COMGETTER(Machines)(ComSafeArrayAsOutParam(machines));
     119    if (SUCCEEDED(hrc))
    120120    {
    121121        /*
     
    155155        }
    156156
    157         if (   SUCCEEDED(rc)
     157        if (   SUCCEEDED(hrc)
    158158            && !listVM.empty())
    159159        {
     
    197197                        case AutostopType_SaveState:
    198198                        {
    199                             rc = autostartSaveVMState(console);
     199                            hrc = autostartSaveVMState(console);
    200200                            break;
    201201                        }
     
    204204                            CHECK_ERROR_BREAK(console, PowerDown(progress.asOutParam()));
    205205
    206                             rc = showProgress(progress);
     206                            hrc = showProgress(progress);
    207207                            CHECK_PROGRESS_ERROR(progress, ("Failed to powering off machine '%ls'", strName.raw()));
    208                             if (FAILED(rc))
    209                                 autostartSvcLogError("Powering off machine '%ls' failed with %Rhrc\n", strName.raw(), rc);
     208                            if (FAILED(hrc))
     209                                autostartSvcLogError("Powering off machine '%ls' failed with %Rhrc\n", strName.raw(), hrc);
    210210                            break;
    211211                        }
     
    240240                                autostartSvcLogWarning("The guest of machine '%ls' does not support ACPI shutdown or is currently paused, saving state...\n",
    241241                                                       strName.raw());
    242                                 rc = autostartSaveVMState(console);
     242                                hrc = autostartSaveVMState(console);
    243243                            }
    244244                            break;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette