VirtualBox

Changeset 73218 in vbox for trunk/src/VBox/Main


Ignore:
Timestamp:
Jul 18, 2018 4:19:08 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
123823
Message:

CloudUserProfileManager::getProfilesByProvider: Use IPRT for building paths correctly. Pointed out a whole bunch of error code blunders.

Location:
trunk/src/VBox/Main/src-server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/CloudUserProfileListImpl.cpp

    r73216 r73218  
    149149    HRESULT hrc = S_OK;
    150150    if (aSectionName.isEmpty())
    151         hrc = VERR_INVALID_PARAMETER;
     151        hrc = VERR_INVALID_PARAMETER; /** @todo r=bird: You're mixing error codes... */
    152152    else
    153153        mSections.insert(make_pair(aSectionName, section));
     
    408408            if (FAILED(hrc))
    409409            {
    410                 throw hrc;
     410                throw hrc; /** @todo r=bird: WTF? Try return it! */
    411411            }
    412412            LogRel(("Successfully parsed %d profiles\n", mpProfiles->getNumberOfSections()));
     
    416416    {
    417417        LogRel(("Empty path to config file\n"));
    418         hrc = VERR_INVALID_PARAMETER;
     418        hrc = VERR_INVALID_PARAMETER; /** @todo r=bird: You're mixing error codes... */
    419419    }
    420420
     
    464464    }
    465465    else
    466         hrc = VERR_NOT_FOUND;
     466        hrc = VERR_NOT_FOUND; /** @todo r=bird: You're mixing error codes... */
    467467
    468468    return hrc;
     
    474474    aProfilesNames = mpProfiles->getSectionsNames();
    475475    if (aProfilesNames.empty())
    476         hrc = VERR_NOT_FOUND;
     476        hrc = VERR_NOT_FOUND; /** @todo r=bird: You're mixing error codes... */
    477477
    478478    return hrc;
     
    503503    }
    504504    else
    505         hrc = VERR_NOT_FOUND;
     505        hrc = VERR_NOT_FOUND; /** @todo r=bird: You're mixing error codes... */
    506506
    507507    return hrc;
     
    545545        hrc = mpProfiles->updateSection(aProfileName, aProfile);
    546546    else
    547         hrc = VERR_NOT_FOUND;
     547        hrc = VERR_NOT_FOUND; /** @todo r=bird: You're mixing error codes... */
    548548
    549549    return hrc;
     
    572572        aProfile = reqProfile;
    573573    else
    574         hrc = VERR_NOT_FOUND;
    575 
    576     return hrc;
    577 }
    578 
     574        hrc = VERR_NOT_FOUND; /** @todo r=bird: You're mixing error codes... */
     575
     576    return hrc;
     577}
     578
  • trunk/src/VBox/Main/src-server/CloudUserProfileManagerImpl.cpp

    r73204 r73218  
    128128                if (SUCCEEDED(hrc))
    129129                {
    130                     char szHomeDir[RTPATH_MAX];
    131                     int vrc = RTPathUserHome(szHomeDir, sizeof(szHomeDir));
     130                    char szOciConfigPath[RTPATH_MAX];
     131                    int vrc = RTPathUserHome(szOciConfigPath, sizeof(szOciConfigPath));
     132                    if (RT_SUCCESS(vrc))
     133                        vrc = RTPathAppend(szOciConfigPath, sizeof(szOciConfigPath), ".oci" RTPATH_SLASH_STR "config");
    132134                    if (RT_SUCCESS(vrc))
    133135                    {
    134                         Utf8Str strConfigPath(szHomeDir);
    135                         strConfigPath.append(RTPATH_SLASH_STR)
    136                                      .append(".oci")
    137                                      .append(RTPATH_SLASH_STR)
    138                                      .append("config");
    139                         LogRel(("config = %s\n", strConfigPath.c_str()));
    140                         if (RTFileExists(strConfigPath.c_str()))
     136                        LogRel(("config = %s\n", szOciConfigPath));
     137                        if (RTFileExists(szOciConfigPath))
    141138                        {
    142                             hrc = ptrOCIUserProfileList->readProfiles(strConfigPath);
     139                            hrc = ptrOCIUserProfileList->readProfiles(szOciConfigPath);
    143140                            if (SUCCEEDED(hrc))
    144                             {
    145                                 LogRel(("Reading profiles from %s has been done\n", strConfigPath.c_str()));
    146                             }
     141                                LogRel(("Reading profiles from %s has been done\n", szOciConfigPath));
    147142                            else
    148                             {
    149                                 LogRel(("Reading profiles from %s hasn't been done\n", strConfigPath.c_str()));
    150                             }
     143                                LogRel(("Reading profiles from %s hasn't been done\n", szOciConfigPath));
    151144
    152145                            ptrCloudUserProfileList = ptrOCIUserProfileList;
     
    154147                        }
    155148                        else
    156                         {
    157                             hrc = setError(VERR_FILE_NOT_FOUND, tr("Could not locate the config file '%s'"),
    158                                            strConfigPath.c_str());
    159                         }
     149                            /** @todo r=bird: You are constantly mixing up status codes.
     150                             * VERR_FILE_NOT_FOUND, VERR_INVALID_PARAMETER and VERR_NOT_FOUND are all VBox
     151                             * status codes.  They don't work for HRESULT types, because that's for
     152                             * COM/XPCOM status codes.   Here you should use setErrorBoth or setErrorVrc. */
     153                            hrc = setError(VERR_FILE_NOT_FOUND, tr("Could not locate the config file '%s'"), szOciConfigPath);
    160154                    }
    161155                    else
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