VirtualBox

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


Ignore:
Timestamp:
Jul 11, 2020 11:41:06 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
139233
Message:

Main/MachineImpl.cpp: Use printf and appendPrintf rather than Utf8StrFmt assignements. Also, don't try initialize a Utf8Str with a Utf8StrFmt, just make the type the latter and save the extra copying. Some signed/unsigned conversion issues. bugref:9790

File:
1 edited

Legend:

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

    r84618 r85256  
    165165{
    166166    /* default values for a newly created machine */
    167     mHWVersion = Utf8StrFmt("%d", SchemaDefs::DefaultHardwareVersion);
     167    mHWVersion.printf("%d", SchemaDefs::DefaultHardwareVersion);
    168168    mMemorySize = 128;
    169169    mCPUCount = 1;
     
    43464346                                              LONG aDevice)
    43474347{
    4348     int rc = S_OK;
    43494348    LogFlowThisFunc(("aName=\"%s\" aControllerPort=%d aDevice=%d\n",
    43504349                     aName.c_str(), aControllerPort, aDevice));
    43514350
    4352     rc = setBandwidthGroupForDevice(aName, aControllerPort, aDevice, NULL);
    4353 
    4354     return rc;
     4351    return setBandwidthGroupForDevice(aName, aControllerPort, aDevice, NULL);
    43554352}
    43564353
     
    44174414                                           DeviceType_T aType)
    44184415{
    4419      HRESULT rc = S_OK;
    4420 
    44214416     LogFlowThisFunc(("aName=\"%s\" aControllerPort=%d aDevice=%d aType=%d\n",
    44224417                      aName.c_str(), aControllerPort, aDevice, aType));
    44234418
    4424      rc = attachDevice(aName, aControllerPort, aDevice, aType, NULL);
    4425 
    4426      return rc;
     4419     return attachDevice(aName, aControllerPort, aDevice, aType, NULL);
    44274420}
    44284421
     
    44334426                               BOOL aForce)
    44344427{
    4435      int rc = S_OK;
    44364428     LogFlowThisFunc(("aName=\"%s\" aControllerPort=%d aDevice=%d",
    44374429                      aName.c_str(), aControllerPort, aForce));
    44384430
    4439      rc = mountMedium(aName, aControllerPort, aDevice, NULL, aForce);
    4440 
    4441      return rc;
     4431     return mountMedium(aName, aControllerPort, aDevice, NULL, aForce);
    44424432}
    44434433
     
    44484438                             BOOL aForce)
    44494439{
    4450     int rc = S_OK;
    44514440    LogFlowThisFunc(("aName=\"%s\" aControllerPort=%d aDevice=%d aForce=%d\n",
    44524441                     aName.c_str(), aControllerPort, aDevice, aForce));
     
    45304519    mediumLock.release();
    45314520    multiLock.release();
    4532     rc = i_onMediumChange(pAttach, aForce);
     4521    HRESULT rc = i_onMediumChange(pAttach, aForce);
    45334522    multiLock.acquire();
    45344523    mediumLock.acquire();
     
    51155104               See the fSafe parameter of xml::XmlFileWriter::write for details. */
    51165105            /** @todo Find a way to avoid referring directly to iprt/xml.h here. */
    5117             Utf8Str otherXml = Utf8StrFmt("%s%s", mData->m_strConfigFileFull.c_str(), xml::XmlFileWriter::s_pszTmpSuff);
     5106            Utf8StrFmt otherXml("%s%s", mData->m_strConfigFileFull.c_str(), xml::XmlFileWriter::s_pszTmpSuff);
    51185107            RTFileDelete(otherXml.c_str());
    5119             otherXml = Utf8StrFmt("%s%s", mData->m_strConfigFileFull.c_str(), xml::XmlFileWriter::s_pszPrevSuff);
     5108            otherXml.printf("%s%s", mData->m_strConfigFileFull.c_str(), xml::XmlFileWriter::s_pszPrevSuff);
    51205109            RTFileDelete(otherXml.c_str());
    51215110
     
    51325121                 * Console::powerUpThread()). Also, delete the VBox.png[.N]
    51335122                 * files that may have been created by the GUI. */
    5134                 Utf8Str log = Utf8StrFmt("%s%cVBox.log",
    5135                                          logFolder.c_str(), RTPATH_DELIMITER);
     5123                Utf8StrFmt log("%s%cVBox.log", logFolder.c_str(), RTPATH_DELIMITER);
    51365124                RTFileDelete(log.c_str());
    5137                 log = Utf8StrFmt("%s%cVBox.png",
    5138                                  logFolder.c_str(), RTPATH_DELIMITER);
     5125                log.printf("%s%cVBox.png", logFolder.c_str(), RTPATH_DELIMITER);
    51395126                RTFileDelete(log.c_str());
    5140                 for (int i = uLogHistoryCount; i > 0; i--)
     5127                for (ULONG i = uLogHistoryCount; i > 0; i--)
    51415128                {
    5142                     log = Utf8StrFmt("%s%cVBox.log.%d",
    5143                                      logFolder.c_str(), RTPATH_DELIMITER, i);
     5129                    log.printf("%s%cVBox.log.%u", logFolder.c_str(), RTPATH_DELIMITER, i);
    51445130                    RTFileDelete(log.c_str());
    5145                     log = Utf8StrFmt("%s%cVBox.png.%d",
    5146                                      logFolder.c_str(), RTPATH_DELIMITER, i);
     5131                    log.printf("%s%cVBox.png.%u", logFolder.c_str(), RTPATH_DELIMITER, i);
    51475132                    RTFileDelete(log.c_str());
    51485133                }
    51495134#if defined(RT_OS_WINDOWS)
    5150                 log = Utf8StrFmt("%s%cVBoxStartup.log", logFolder.c_str(), RTPATH_DELIMITER);
     5135                log.printf("%s%cVBoxStartup.log", logFolder.c_str(), RTPATH_DELIMITER);
    51515136                RTFileDelete(log.c_str());
    5152                 log = Utf8StrFmt("%s%cVBoxHardening.log", logFolder.c_str(), RTPATH_DELIMITER);
     5137                log.printf("%s%cVBoxHardening.log", logFolder.c_str(), RTPATH_DELIMITER);
    51535138                RTFileDelete(log.c_str());
    51545139#endif
     
    71427127            vrc = RTPathAbs(szTmp, szTmp2, sizeof(szTmp2));
    71437128            if (RT_SUCCESS(vrc))
    7144                 aLogFolder = Utf8StrFmt("%s%c%s",
    7145                                         szTmp2,
    7146                                         RTPATH_DELIMITER,
    7147                                         mUserData->s.strName.c_str()); // path/to/logfolder/vmname
     7129                aLogFolder.printf("%s%c%s",
     7130                                  szTmp2,
     7131                                  RTPATH_DELIMITER,
     7132                                  mUserData->s.strName.c_str()); // path/to/logfolder/vmname
    71487133        }
    71497134        else
     
    71727157    Utf8Str log;
    71737158    if (idx == 0)
    7174         log = Utf8StrFmt("%s%cVBox.log", logFolder.c_str(), RTPATH_DELIMITER);
     7159        log.printf("%s%cVBox.log", logFolder.c_str(), RTPATH_DELIMITER);
    71757160#if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_HARDENING)
    71767161    else if (idx == 1)
    7177         log = Utf8StrFmt("%s%cVBoxHardening.log", logFolder.c_str(), RTPATH_DELIMITER);
     7162        log.printf("%s%cVBoxHardening.log", logFolder.c_str(), RTPATH_DELIMITER);
    71787163    else
    7179         log = Utf8StrFmt("%s%cVBox.log.%u", logFolder.c_str(), RTPATH_DELIMITER, idx - 1);
     7164        log.printf("%s%cVBox.log.%u", logFolder.c_str(), RTPATH_DELIMITER, idx - 1);
    71807165#else
    71817166    else
    7182         log = Utf8StrFmt("%s%cVBox.log.%u", logFolder.c_str(), RTPATH_DELIMITER, idx);
     7167        log.printf("%s%cVBox.log.%u", logFolder.c_str(), RTPATH_DELIMITER, idx);
    71837168#endif
    71847169    return log;
     
    72427227    Utf8Str strNVRAMFilePath = mUserData->s.strSnapshotFolder;
    72437228    strNVRAMFilePath += RTPATH_DELIMITER;
    7244     strNVRAMFilePath += Utf8StrFmt("%04d-%02u-%02uT%02u-%02u-%02u-%09uZ.nvram",
    7245                                    time.i32Year, time.u8Month, time.u8MonthDay,
    7246                                    time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond);
     7229    strNVRAMFilePath.appendPrintf("%04d-%02u-%02uT%02u-%02u-%02u-%09uZ.nvram",
     7230                                  time.i32Year, time.u8Month, time.u8MonthDay,
     7231                                  time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond);
    72477232
    72487233    return strNVRAMFilePath;
     
    72837268
    72847269    strStateFilePath += RTPATH_DELIMITER;
    7285     strStateFilePath += Utf8StrFmt("%04d-%02u-%02uT%02u-%02u-%02u-%09uZ.sav",
    7286                                    time.i32Year, time.u8Month, time.u8MonthDay,
    7287                                    time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond);
     7270    strStateFilePath.appendPrintf("%04d-%02u-%02uT%02u-%02u-%02u-%09uZ.sav",
     7271                                  time.i32Year, time.u8Month, time.u8MonthDay,
     7272                                  time.u8Hour, time.u8Minute, time.u8Second, time.u32Nanosecond);
    72887273}
    72897274
     
    77497734        int vrc2 = RTFileQuerySizeByPath(strHardeningLogFile.c_str(), &cbStartupLogFile);
    77507735        if (RT_SUCCESS(vrc2) && cbStartupLogFile > 0)
    7751             strExtraInfo.append(Utf8StrFmt(tr(".  More details may be available in '%s'"), strHardeningLogFile.c_str()));
     7736            strExtraInfo.appendPrintf(tr(".  More details may be available in '%s'"), strHardeningLogFile.c_str());
    77527737#endif
    77537738
     
    95439528
    95449529            /* first, rename the directory if it matches the group and machine name */
    9545             Utf8Str groupPlusName = Utf8StrFmt("%s%c%s",
    9546                 group.c_str(), RTPATH_DELIMITER, name.c_str());
     9530            Utf8StrFmt groupPlusName("%s%c%s", group.c_str(), RTPATH_DELIMITER, name.c_str());
    95479531            /** @todo hack, make somehow use of ComposeMachineFilename */
    95489532            if (mUserData->s.fDirectoryIncludesUUID)
    9549                 groupPlusName += Utf8StrFmt(" (%RTuuid)", mData->mUuid.raw());
    9550             Utf8Str newGroupPlusName = Utf8StrFmt("%s%c%s",
    9551                 newGroup.c_str(), RTPATH_DELIMITER, newName.c_str());
     9533                groupPlusName.appendPrintf(" (%RTuuid)", mData->mUuid.raw());
     9534            Utf8StrFmt newGroupPlusName("%s%c%s", newGroup.c_str(), RTPATH_DELIMITER, newName.c_str());
    95529535            /** @todo hack, make somehow use of ComposeMachineFilename */
    95539536            if (mUserData->s.fDirectoryIncludesUUID)
    9554                 newGroupPlusName += Utf8StrFmt(" (%RTuuid)", mData->mUuid.raw());
     9537                newGroupPlusName.appendPrintf(" (%RTuuid)", mData->mUuid.raw());
    95559538            configDir = configFile;
    95569539            configDir.stripFilename();
     
    96049587            }
    96059588
    9606             newConfigFile = Utf8StrFmt("%s%c%s.vbox",
    9607                 newConfigDir.c_str(), RTPATH_DELIMITER, newName.c_str());
     9589            newConfigFile.printf("%s%c%s.vbox", newConfigDir.c_str(), RTPATH_DELIMITER, newName.c_str());
    96089590
    96099591            /* then try to rename the settings file itself */
     
    96119593            {
    96129594                /* get the path to old settings file in renamed directory */
    9613                 configFile = Utf8StrFmt("%s%c%s",
    9614                                         newConfigDir.c_str(),
    9615                                         RTPATH_DELIMITER,
    9616                                         RTPathFilename(configFile.c_str()));
     9595                configFile.printf("%s%c%s",
     9596                                  newConfigDir.c_str(),
     9597                                  RTPATH_DELIMITER,
     9598                                  RTPathFilename(configFile.c_str()));
    96179599                if (!fSettingsFileIsNew)
    96189600                {
     
    1003210014             && mSSData->strStateFilePath.isEmpty()
    1003310015           )
    10034             mHWData->mHWVersion = Utf8StrFmt("%d", SchemaDefs::DefaultHardwareVersion);
     10016            mHWData->mHWVersion.printf("%d", SchemaDefs::DefaultHardwareVersion);
    1003510017
    1003610018        data.strVersion = mHWData->mHWVersion;
     
    1153011512    /** @todo hack, make somehow use of ComposeMachineFilename */
    1153111513    if (mUserData->s.fDirectoryIncludesUUID)
    11532         strConfigFileOnly += Utf8StrFmt(" (%RTuuid)", mData->mUuid.raw());
     11514        strConfigFileOnly.appendPrintf(" (%RTuuid)", mData->mUuid.raw());
    1153311515
    1153411516    AssertReturn(!strMachineDirName.isEmpty(), false);
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