VirtualBox

Changeset 91518 in vbox


Ignore:
Timestamp:
Oct 1, 2021 2:31:06 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
147210
Message:

Main/GuestCtrl: Use RTCString::printf instead of Utf8StrFmt + assignment operator. Also, use %Rrc instead of RTErrQueryDefine + %s.

Location:
trunk/src/VBox/Main/src-client
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/GuestDirectoryImpl.cpp

    r91516 r91518  
    8383        /* Start the directory process on the guest. */
    8484        GuestProcessStartupInfo procInfo;
    85         procInfo.mName      = Utf8StrFmt(tr("Opening directory \"%s\""), openInfo.mPath.c_str());
     85        procInfo.mName.printf(tr("Opening directory \"%s\""), openInfo.mPath.c_str());
    8686        procInfo.mTimeoutMS = 5 * 60 * 1000; /* 5 minutes timeout. */
    8787        procInfo.mFlags     = ProcessCreateFlag_WaitForStdOut;
     
    236236
    237237    Utf8Str strErr;
    238 
     238    switch (rcGuest)
     239    {
    239240#define CASE_MSG(a_iRc, ...) \
    240     case a_iRc: strErr = Utf8StrFmt(__VA_ARGS__); break;
    241 
    242     /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    243     switch (rcGuest)
    244     {
     241        case a_iRc: strErr.printf(__VA_ARGS__); break;
    245242        CASE_MSG(VERR_CANT_CREATE  , tr("Access to guest directory \"%s\" is denied"), pcszWhat);
    246243        CASE_MSG(VERR_DIR_NOT_EMPTY, tr("Guest directory \"%s\" is not empty"), pcszWhat);
    247244        default:
    248         {
    249             char szDefine[80];
    250             RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/);
    251             strErr = Utf8StrFmt(tr("Error %s for guest directory \"%s\" occurred\n"), szDefine, pcszWhat);
     245            strErr.printf(tr("Error %Rrc for guest directory \"%s\" occurred\n"), rcGuest, pcszWhat);
    252246            break;
    253         }
    254247    }
    255248
  • trunk/src/VBox/Main/src-client/GuestFileImpl.cpp

    r91516 r91518  
    416416
    417417    Utf8Str strErr;
    418 
     418    switch (rcGuest)
     419    {
    419420#define CASE_MSG(a_iRc, ...) \
    420     case a_iRc: strErr = Utf8StrFmt(__VA_ARGS__); break;
    421 
    422     /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    423     switch (rcGuest)
    424     {
     421        case a_iRc: strErr.printf(__VA_ARGS__); break;
    425422        CASE_MSG(VERR_ACCESS_DENIED     , tr("Access to guest file \"%s\" denied"), pcszWhat);
    426423        CASE_MSG(VERR_ALREADY_EXISTS    , tr("Guest file \"%s\" already exists"), pcszWhat);
     
    429426        CASE_MSG(VERR_SHARING_VIOLATION , tr("Sharing violation for guest file \"%s\""), pcszWhat);
    430427        default:
    431         {
    432             char szDefine[80];
    433             RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/);
    434             strErr = Utf8StrFmt(tr("Error %s for guest file \"%s\" occurred\n"), szDefine, pcszWhat);
    435             break;
    436         }
    437     }
    438 
     428            strErr.printf(tr("Error %Rrc for guest file \"%s\" occurred\n"), rcGuest, pcszWhat);
     429            break;
    439430#undef CASE_MSG
     431    }
    440432
    441433    return strErr;
  • trunk/src/VBox/Main/src-client/GuestProcessImpl.cpp

    r91517 r91518  
    500500
    501501    Utf8Str strErr;
    502 
     502    switch (rcGuest)
     503    {
    503504#define CASE_MSG(a_iRc, ...) \
    504     case a_iRc: strErr = Utf8StrFmt( __VA_ARGS__); break;
    505 
    506     /** @todo pData->u32Flags: int vs. uint32 -- IPRT errors are *negative* !!! */
    507     switch (rcGuest)
    508     {
     505        case a_iRc: strErr.printf(__VA_ARGS__); break;
     506
    509507        CASE_MSG(VERR_FILE_NOT_FOUND,                 tr("No such file or directory \"%s\" on guest"), pcszWhat); /* This is the most likely error. */
    510508        CASE_MSG(VERR_PATH_NOT_FOUND,                 tr("No such file or directory \"%s\" on guest"), pcszWhat);
     
    519517        CASE_MSG(VERR_NOT_FOUND,                      tr("The guest execution service is not ready (yet)"));
    520518        default:
    521         {
    522             char szDefine[80];
    523             RTErrQueryDefine(rcGuest, szDefine, sizeof(szDefine), false /*fFailIfUnknown*/);
    524             strErr = Utf8StrFmt(tr("Error %s for guest process \"%s\" occurred\n"), szDefine, pcszWhat);
    525             break;
    526         }
    527     }
    528 
     519            strErr.printf(tr("Error %Rrc for guest process \"%s\" occurred\n"), rcGuest, pcszWhat);
     520            break;
    529521#undef CASE_MSG
     522    }
    530523
    531524    return strErr;
     
    26112604
    26122605/* static */
    2613 Utf8Str GuestProcessTool::guestErrorToString(const char *pszTool, const GuestErrorInfo& guestErrorInfo)
     2606Utf8Str GuestProcessTool::guestErrorToString(const char *pszTool, const GuestErrorInfo &guestErrorInfo)
    26142607{
    26152608    Utf8Str strErr;
     
    26192612    {
    26202613        case VERR_ACCESS_DENIED:
    2621             strErr = Utf8StrFmt(tr("Access to \"%s\" denied"), guestErrorInfo.getWhat().c_str());
     2614            strErr.printf(tr("Access to \"%s\" denied"), guestErrorInfo.getWhat().c_str());
    26222615            break;
    26232616
     
    26252618            RT_FALL_THROUGH();
    26262619        case VERR_PATH_NOT_FOUND:
    2627             strErr = Utf8StrFmt(tr("No such file or directory \"%s\""), guestErrorInfo.getWhat().c_str());
     2620            strErr.printf(tr("No such file or directory \"%s\""), guestErrorInfo.getWhat().c_str());
    26282621            break;
    26292622
    26302623        case VERR_INVALID_VM_HANDLE:
    2631             strErr = Utf8StrFmt(tr("VMM device is not available (is the VM running?)"));
     2624            strErr.printf(tr("VMM device is not available (is the VM running?)"));
    26322625            break;
    26332626
    26342627        case VERR_HGCM_SERVICE_NOT_FOUND:
    2635             strErr = Utf8StrFmt(tr("The guest execution service is not available"));
     2628            strErr.printf(tr("The guest execution service is not available"));
    26362629            break;
    26372630
    26382631        case VERR_BAD_EXE_FORMAT:
    2639             strErr = Utf8StrFmt(tr("The file \"%s\" is not an executable format"),
    2640                                 guestErrorInfo.getWhat().c_str());
     2632            strErr.printf(tr("The file \"%s\" is not an executable format"), guestErrorInfo.getWhat().c_str());
    26412633            break;
    26422634
    26432635        case VERR_AUTHENTICATION_FAILURE:
    2644             strErr = Utf8StrFmt(tr("The user \"%s\" was not able to logon"), guestErrorInfo.getWhat().c_str());
     2636            strErr.printf(tr("The user \"%s\" was not able to logon"), guestErrorInfo.getWhat().c_str());
    26452637            break;
    26462638
    26472639        case VERR_INVALID_NAME:
    2648             strErr = Utf8StrFmt(tr("The file \"%s\" is an invalid name"), guestErrorInfo.getWhat().c_str());
     2640            strErr.printf(tr("The file \"%s\" is an invalid name"), guestErrorInfo.getWhat().c_str());
    26492641            break;
    26502642
    26512643        case VERR_TIMEOUT:
    2652             strErr = Utf8StrFmt(tr("The guest did not respond within time"));
     2644            strErr.printf(tr("The guest did not respond within time"));
    26532645            break;
    26542646
    26552647        case VERR_CANCELLED:
    2656             strErr = Utf8StrFmt(tr("The execution operation was canceled"));
     2648            strErr.printf(tr("The execution operation was canceled"));
    26572649            break;
    26582650
    26592651        case VERR_GSTCTL_MAX_CID_OBJECTS_REACHED:
    2660             strErr = Utf8StrFmt(tr("Maximum number of concurrent guest processes has been reached"));
     2652            strErr.printf(tr("Maximum number of concurrent guest processes has been reached"));
    26612653            break;
    26622654
    26632655        case VERR_NOT_FOUND:
    2664             strErr = Utf8StrFmt(tr("The guest execution service is not ready (yet)"));
     2656            strErr.printf(tr("The guest execution service is not ready (yet)"));
    26652657            break;
    26662658
    26672659        default:
    2668             strErr = Utf8StrFmt(tr("Unhandled error %Rrc for \"%s\" occurred for tool \"%s\" on guest -- please file a bug report"),
    2669                                 guestErrorInfo.getRc(), guestErrorInfo.getWhat().c_str(), pszTool);
     2660            strErr.printf(tr("Unhandled error %Rrc for \"%s\" occurred for tool \"%s\" on guest -- please file a bug report"),
     2661                          guestErrorInfo.getRc(), guestErrorInfo.getWhat().c_str(), pszTool);
    26702662            break;
    26712663    }
Note: See TracChangeset for help on using the changeset viewer.

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