VirtualBox

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


Ignore:
Timestamp:
Aug 12, 2016 6:29:33 PM (8 years ago)
Author:
vboxsync
Message:

Main: warnings (gcc)

Location:
trunk/src/VBox/Main
Files:
4 edited

Legend:

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

    r63187 r63378  
    160160
    161161    TaskVFSExplorer(TaskType aTaskType, VFSExplorer *aThat, Progress *aProgress)
    162         : taskType(aTaskType),
    163           pVFSExplorer(aThat),
    164           progress(aProgress),
    165           rc(S_OK)
     162        : m_taskType(aTaskType),
     163          m_pVFSExplorer(aThat),
     164          m_ptrProgress(aProgress),
     165          m_rc(S_OK)
    166166    {
    167167        m_strTaskName = "Explorer::Task";
     
    176176#endif
    177177
    178     TaskType taskType;
    179     VFSExplorer *pVFSExplorer;
    180 
    181     ComObjPtr<Progress> progress;
    182     HRESULT rc;
     178    TaskType m_taskType;
     179    VFSExplorer *m_pVFSExplorer;
     180
     181    ComObjPtr<Progress> m_ptrProgress;
     182    HRESULT m_rc;
    183183
    184184    /* task data */
    185     std::list<Utf8Str> filenames;
     185    std::list<Utf8Str> m_lstFilenames;
    186186
    187187    friend class VFSExplorer;
     
    191191void VFSExplorer::TaskVFSExplorer::handler()
    192192{
    193     VFSExplorer *pVFSExplorer = this->pVFSExplorer;
     193    VFSExplorer *pVFSExplorer = this->m_pVFSExplorer;
    194194
    195195    LogFlowFuncEnter();
     
    198198    HRESULT rc = S_OK;
    199199
    200     switch (this->taskType)
     200    switch (this->m_taskType)
    201201    {
    202202        case TaskVFSExplorer::Update:
     
    217217        }
    218218        default:
    219             AssertMsgFailed(("Invalid task type %u specified!\n", this->taskType));
     219            AssertMsgFailed(("Invalid task type %u specified!\n", this->m_taskType));
    220220            break;
    221221    }
     
    232232
    233233    if (pTask &&
    234         !pTask->progress.isNull())
     234        !pTask->m_ptrProgress.isNull())
    235235    {
    236236        BOOL fCanceled;
    237         pTask->progress->COMGETTER(Canceled)(&fCanceled);
     237        pTask->m_ptrProgress->COMGETTER(Canceled)(&fCanceled);
    238238        if (fCanceled)
    239239            return -1;
    240         pTask->progress->SetCurrentOperationProgress(uPercent);
     240        pTask->m_ptrProgress->SetCurrentOperationProgress(uPercent);
    241241    }
    242242    return VINF_SUCCESS;
     
    288288            throw setError(VBOX_E_FILE_ERROR, tr ("Can't open directory '%s' (%Rrc)"), pszPath, vrc);
    289289
    290         if (aTask->progress)
    291             aTask->progress->SetCurrentOperationProgress(33);
     290        if (aTask->m_ptrProgress)
     291            aTask->m_ptrProgress->SetCurrentOperationProgress(33);
    292292        RTDIRENTRYEX entry;
    293293        while (RT_SUCCESS(vrc))
     
    304304            }
    305305        }
    306         if (aTask->progress)
    307             aTask->progress->SetCurrentOperationProgress(66);
     306        if (aTask->m_ptrProgress)
     307            aTask->m_ptrProgress->SetCurrentOperationProgress(66);
    308308    }
    309309    catch(HRESULT aRC)
     
    318318        RTDirClose(pDir);
    319319
    320     if (aTask->progress)
    321         aTask->progress->SetCurrentOperationProgress(99);
     320    if (aTask->m_ptrProgress)
     321        aTask->m_ptrProgress->SetCurrentOperationProgress(99);
    322322
    323323    /* Assign the result on success (this clears the old list) */
     
    325325        m->entryList.assign(fileList.begin(), fileList.end());
    326326
    327     aTask->rc = rc;
    328 
    329     if (!aTask->progress.isNull())
    330         aTask->progress->i_notifyComplete(rc);
     327    aTask->m_rc = rc;
     328
     329    if (!aTask->m_ptrProgress.isNull())
     330        aTask->m_ptrProgress->i_notifyComplete(rc);
    331331
    332332    LogFlowFunc(("rc=%Rhrc\n", rc));
     
    347347    HRESULT rc = S_OK;
    348348
    349     float fPercentStep = 100.0f / (float)aTask->filenames.size();
     349    float fPercentStep = 100.0f / (float)aTask->m_lstFilenames.size();
    350350    try
    351351    {
     
    353353        std::list<Utf8Str>::const_iterator it;
    354354        size_t i = 0;
    355         for (it = aTask->filenames.begin();
    356              it != aTask->filenames.end();
     355        for (it = aTask->m_lstFilenames.begin();
     356             it != aTask->m_lstFilenames.end();
    357357             ++it, ++i)
    358358        {
     
    363363            if (RT_FAILURE(vrc))
    364364                throw setError(VBOX_E_FILE_ERROR, tr("Can't delete file '%s' (%Rrc)"), szPath, vrc);
    365             if (aTask->progress)
    366                 aTask->progress->SetCurrentOperationProgress((ULONG)(fPercentStep * (float)i));
     365            if (aTask->m_ptrProgress)
     366                aTask->m_ptrProgress->SetCurrentOperationProgress((ULONG)(fPercentStep * (float)i));
    367367        }
    368368    }
    369     catch(HRESULT aRC)
     369    catch (HRESULT aRC)
    370370    {
    371371        rc = aRC;
    372372    }
    373373
    374     aTask->rc = rc;
    375 
    376     if (!aTask->progress.isNull())
    377         aTask->progress->i_notifyComplete(rc);
     374    aTask->m_rc = rc;
     375
     376    if (aTask->m_ptrProgress.isNotNull())
     377        aTask->m_ptrProgress->i_notifyComplete(rc);
    378378
    379379    LogFlowFunc(("rc=%Rhrc\n", rc));
     
    522522        /* Add all filenames to delete as task data */
    523523        for (size_t i = 0; i < aNames.size(); ++i)
    524             pTask->filenames.push_back(aNames[i]);
     524            pTask->m_lstFilenames.push_back(aNames[i]);
    525525
    526526        //this function delete task in case of exceptions, so there is no need in the call of delete operator
  • trunk/src/VBox/Main/src-server/linux/USBGetDevices.cpp

    r62363 r63378  
    459459
    460460/** Just a worker for USBProxyServiceLinux::getDevices that avoids some code duplication. */
    461 static int usbfsAddDeviceToChain(PUSBDEVICE pDev, PUSBDEVICE *ppFirst, PUSBDEVICE **pppNext, const char *pcszUsbfsRoot,
    462                                  bool testfs, int rc)
     461static int usbfsAddDeviceToChain(PUSBDEVICE pDev, PUSBDEVICE *ppFirst, PUSBDEVICE **pppNext, const char *pszUsbfsRoot,
     462                                 bool fUnsupportedDevicesToo, int rc)
    463463{
    464464    /* usbDeterminState requires the address. */
     
    466466    if (pDevNew)
    467467    {
    468         RTStrAPrintf((char **)&pDevNew->pszAddress, "%s/%03d/%03d", pcszUsbfsRoot, pDevNew->bBus, pDevNew->bDevNum);
     468        RTStrAPrintf((char **)&pDevNew->pszAddress, "%s/%03d/%03d", pszUsbfsRoot, pDevNew->bBus, pDevNew->bDevNum);
    469469        if (pDevNew->pszAddress)
    470470        {
    471471            pDevNew->enmState = usbDeterminState(pDevNew);
    472             if (pDevNew->enmState != USBDEVICESTATE_UNSUPPORTED || testfs)
     472            if (pDevNew->enmState != USBDEVICESTATE_UNSUPPORTED || fUnsupportedDevicesToo)
    473473            {
    474474                if (*pppNext)
     
    497497
    498498
    499 static int usbfsOpenDevicesFile(const char *pcszUsbfsRoot, FILE **ppFile)
     499static int usbfsOpenDevicesFile(const char *pszUsbfsRoot, FILE **ppFile)
    500500{
    501501    char *pszPath;
    502502    FILE *pFile;
    503     RTStrAPrintf(&pszPath, "%s/devices", pcszUsbfsRoot);
     503    RTStrAPrintf(&pszPath, "%s/devices", pszUsbfsRoot);
    504504    if (!pszPath)
    505505        return VERR_NO_MEMORY;
     
    514514
    515515/**
    516  * USBProxyService::getDevices() implementation for usbfs.  The @a testfs flag
    517  * tells the function to return information about unsupported devices as well.
    518  * This is used as a sanity test to check that a devices file is really what
    519  * we expect.
    520  */
    521 static PUSBDEVICE usbfsGetDevices(const char *pcszUsbfsRoot, bool testfs)
     516 * USBProxyService::getDevices() implementation for usbfs.
     517 *
     518 * The @a fUnsupportedDevicesToo flag tells the function to return information
     519 * about unsupported devices as well.  This is used as a sanity test to check
     520 * that a devices file is really what we expect.
     521 */
     522static PUSBDEVICE usbfsGetDevices(const char *pszUsbfsRoot, bool fUnsupportedDevicesToo)
    522523{
    523524    PUSBDEVICE pFirst = NULL;
    524525    FILE *pFile = NULL;
    525526    int rc;
    526     rc = usbfsOpenDevicesFile(pcszUsbfsRoot, &pFile);
     527    rc = usbfsOpenDevicesFile(pszUsbfsRoot, &pFile);
    527528    if (RT_SUCCESS(rc))
    528529    {
     
    535536
    536537        /* Set close on exit and hope no one is racing us. */
    537         rc =   fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0
    538              ? VINF_SUCCESS
    539              : RTErrConvertFromErrno(errno);
     538        rc = fcntl(fileno(pFile), F_SETFD, FD_CLOEXEC) >= 0
     539           ? VINF_SUCCESS
     540           : RTErrConvertFromErrno(errno);
    540541        while (     RT_SUCCESS(rc)
    541542               &&   fgets(szLine, sizeof(szLine), pFile))
     
    584585                    AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits));
    585586                    if (cHits >= 3)
    586                         rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pcszUsbfsRoot, testfs, rc);
     587                        rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, rc);
    587588                    else
    588589                        deviceFreeMembers(&Dev);
     
    777778        AssertMsg(cHits >= 3 || cHits == 0, ("cHits=%d\n", cHits));
    778779        if (cHits >= 3)
    779             rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pcszUsbfsRoot, testfs, rc);
     780            rc = usbfsAddDeviceToChain(&Dev, &pFirst, &ppNext, pszUsbfsRoot, fUnsupportedDevicesToo, rc);
    780781
    781782        /*
     
    836837 * @returns a bus number greater than 0 on success or 0 on failure.
    837838 */
    838 static unsigned usbsysfsGetBusFromPath(const char *pcszPath)
    839 {
    840     const char *pcszFile = strrchr(pcszPath, '/');
    841     if (!pcszFile)
     839static unsigned usbsysfsGetBusFromPath(const char *pszPath)
     840{
     841    const char *pszFile = strrchr(pszPath, '/');
     842    if (!pszFile)
    842843        return 0;
    843     unsigned bus = RTStrToUInt32(pcszFile + 1);
     844    unsigned bus = RTStrToUInt32(pszFile + 1);
    844845    if (   !bus
    845         && pcszFile[1] == 'u' && pcszFile[2] == 's' && pcszFile[3] == 'b')
    846     bus = RTStrToUInt32(pcszFile + 4);
     846        && pszFile[1] == 'u' && pszFile[2] == 's' && pszFile[3] == 'b')
     847    bus = RTStrToUInt32(pszFile + 4);
    847848    return bus;
    848849}
     
    864865
    865866/**
    866  * If a file @a pcszNode from /sys/bus/usb/devices is a device rather than an
     867 * If a file @a pszNode from /sys/bus/usb/devices is a device rather than an
    867868 * interface add an element for the device to @a pvecDevInfo.
    868869 */
    869 static int usbsysfsAddIfDevice(const char *pcszDevicesRoot, const char *pcszNode, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)
    870 {
    871     const char *pcszFile = strrchr(pcszNode, '/');
    872     if (!pcszFile)
     870static int usbsysfsAddIfDevice(const char *pszDevicesRoot, const char *pszNode, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)
     871{
     872    const char *pszFile = strrchr(pszNode, '/');
     873    if (!pszFile)
    873874        return VERR_INVALID_PARAMETER;
    874     if (strchr(pcszFile, ':'))
     875    if (strchr(pszFile, ':'))
    875876        return VINF_SUCCESS;
    876877
    877     unsigned bus = usbsysfsGetBusFromPath(pcszNode);
     878    unsigned bus = usbsysfsGetBusFromPath(pszNode);
    878879    if (!bus)
    879880        return VINF_SUCCESS;
    880881
    881882    int64_t device;
    882     int rc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", pcszNode);
     883    int rc = RTLinuxSysFsReadIntFile(10, &device, "%s/devnum", pszNode);
    883884    if (RT_FAILURE(rc))
    884885        return VINF_SUCCESS;
     
    892893                                szDevPath, sizeof(szDevPath),
    893894                                "%s/%.3d/%.3d",
    894                                 pcszDevicesRoot, bus, device);
     895                                pszDevicesRoot, bus, device);
    895896    if (RT_FAILURE(rc))
    896897        return VINF_SUCCESS;
    897898
    898899    USBDeviceInfo info;
    899     if (usbsysfsInitDevInfo(&info, szDevPath, pcszNode))
     900    if (usbsysfsInitDevInfo(&info, szDevPath, pszNode))
    900901    {
    901902        rc = VEC_PUSH_BACK_OBJ(pvecDevInfo, USBDeviceInfo, &info);
     
    915916 * as the test requires file-system interaction.
    916917 */
    917 static bool usbsysfsMuiIsAnInterfaceOf(const char *pcszIface, const char *pcszDev)
    918 {
    919     size_t cchDev = strlen(pcszDev);
    920 
    921     AssertPtr(pcszIface);
    922     AssertPtr(pcszDev);
    923     Assert(pcszIface[0] == '/');
    924     Assert(pcszDev[0] == '/');
    925     Assert(pcszDev[cchDev - 1] != '/');
    926 
    927     /* If this passes, pcszIface is at least cchDev long */
    928     if (strncmp(pcszIface, pcszDev, cchDev))
     918static bool usbsysfsMuiIsAnInterfaceOf(const char *pszIface, const char *pszDev)
     919{
     920    size_t cchDev = strlen(pszDev);
     921
     922    AssertPtr(pszIface);
     923    AssertPtr(pszDev);
     924    Assert(pszIface[0] == '/');
     925    Assert(pszDev[0] == '/');
     926    Assert(pszDev[cchDev - 1] != '/');
     927
     928    /* If this passes, pszIface is at least cchDev long */
     929    if (strncmp(pszIface, pszDev, cchDev))
    929930        return false;
    930931
    931     /* If this passes, pcszIface is longer than cchDev */
    932     if (pcszIface[cchDev] != '/')
     932    /* If this passes, pszIface is longer than cchDev */
     933    if (pszIface[cchDev] != '/')
    933934        return false;
    934935
    935936    /* In sysfs an interface is an immediate subdirectory of the device */
    936     if (strchr(pcszIface + cchDev + 1, '/'))
     937    if (strchr(pszIface + cchDev + 1, '/'))
    937938        return false;
    938939
    939940    /* And it always has a colon in its name */
    940     if (!strchr(pcszIface + cchDev + 1, ':'))
     941    if (!strchr(pszIface + cchDev + 1, ':'))
    941942        return false;
    942943
     
    971972 * device.
    972973 */
    973 static int usbsysfsAddIfInterfaceOf(const char *pcszNode, USBDeviceInfo *pInfo)
    974 {
    975     if (!usbsysfsMuiIsAnInterfaceOf(pcszNode, pInfo->mSysfsPath))
     974static int usbsysfsAddIfInterfaceOf(const char *pszNode, USBDeviceInfo *pInfo)
     975{
     976    if (!usbsysfsMuiIsAnInterfaceOf(pszNode, pInfo->mSysfsPath))
    976977        return VINF_SUCCESS;
    977978
    978     char *pszDup = (char *)RTStrDup(pcszNode);
     979    char *pszDup = (char *)RTStrDup(pszNode);
    979980    if (pszDup)
    980981    {
     
    995996 * files on which realpath() fails.
    996997 */
    997 static int usbsysfsReadFilePathsFromDir(const char *pcszPath, DIR *pDir, VECTOR_PTR(char *) *pvecpchDevs)
     998static int usbsysfsReadFilePathsFromDir(const char *pszPath, DIR *pDir, VECTOR_PTR(char *) *pvecpchDevs)
    998999{
    9991000    struct dirent entry, *pResult;
     
    10071008        if (entry.d_name[0] == '.')
    10081009            continue;
    1009         if (snprintf(szPath, sizeof(szPath), "%s/%s", pcszPath, entry.d_name) < 0)
    1010             return RTErrConvertFromErrno(errno); /** @todo r=bird: snprintf isn't document to set errno. Also, wouldn't it be better to continue on errors? Finally, you don't need to copy pcszPath each time... */
     1010        if (snprintf(szPath, sizeof(szPath), "%s/%s", pszPath, entry.d_name) < 0)
     1011            return RTErrConvertFromErrno(errno); /** @todo r=bird: snprintf isn't document to set errno. Also, wouldn't it be better to continue on errors? Finally, you don't need to copy pszPath each time... */
    10111012        if (!realpath(szPath, szRealPath))
    10121013            return RTErrConvertFromErrno(errno);
    1013         char *pszPath = RTStrDup(szRealPath);
    1014         if (!pszPath)
     1014        char *pszPathCopy = RTStrDup(szRealPath);
     1015        if (!pszPathCopy)
    10151016            return VERR_NO_MEMORY;
    1016         if (RT_FAILURE(rc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPath)))
     1017        if (RT_FAILURE(rc = VEC_PUSH_BACK_PTR(pvecpchDevs, char *, pszPathCopy)))
    10171018            return rc;
    10181019    }
     
    10251026 *
    10261027 * @returns zero on success or (positive) posix error value.
    1027  * @param   pcszPath      the path to dump.
     1028 * @param   pszPath      the path to dump.
    10281029 * @param   pvecpchDevs   an empty vector of char pointers - must be cleaned up
    10291030 *                        by the caller even on failure.
    10301031 * @param   withRealPath  whether to canonicalise the filename with realpath
    10311032 */
    1032 static int usbsysfsReadFilePaths(const char *pcszPath, VECTOR_PTR(char *) *pvecpchDevs)
     1033static int usbsysfsReadFilePaths(const char *pszPath, VECTOR_PTR(char *) *pvecpchDevs)
    10331034{
    10341035    AssertPtrReturn(pvecpchDevs, EINVAL);
    10351036    AssertReturn(VEC_SIZE_PTR(pvecpchDevs) == 0, EINVAL);
    1036     AssertPtrReturn(pcszPath, EINVAL);
    1037 
    1038     DIR *pDir = opendir(pcszPath);
     1037    AssertPtrReturn(pszPath, EINVAL);
     1038
     1039    DIR *pDir = opendir(pszPath);
    10391040    if (!pDir)
    10401041        return RTErrConvertFromErrno(errno);
    1041     int rc = usbsysfsReadFilePathsFromDir(pcszPath, pDir, pvecpchDevs);
     1042    int rc = usbsysfsReadFilePathsFromDir(pszPath, pDir, pvecpchDevs);
    10421043    if (closedir(pDir) < 0 && RT_SUCCESS(rc))
    10431044        rc = RTErrConvertFromErrno(errno);
     
    10541055 *                     to simplify exit logic
    10551056 */
    1056 static int usbsysfsEnumerateHostDevicesWorker(const char *pcszDevicesRoot,
     1057static int usbsysfsEnumerateHostDevicesWorker(const char *pszDevicesRoot,
    10571058                                              VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo,
    10581059                                              VECTOR_PTR(char *) *pvecpchDevs)
     
    10691070    VEC_FOR_EACH(pvecpchDevs, char *, ppszEntry)
    10701071    {
    1071         rc = usbsysfsAddIfDevice(pcszDevicesRoot, *ppszEntry, pvecDevInfo);
     1072        rc = usbsysfsAddIfDevice(pszDevicesRoot, *ppszEntry, pvecDevInfo);
    10721073        if (RT_FAILURE(rc))
    10731074            return rc;
     
    10861087
    10871088
    1088 static int usbsysfsEnumerateHostDevices(const char *pcszDevicesRoot, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)
     1089static int usbsysfsEnumerateHostDevices(const char *pszDevicesRoot, VECTOR_OBJ(USBDeviceInfo) *pvecDevInfo)
    10891090{
    10901091    VECTOR_PTR(char *) vecpchDevs;
     
    10931094    LogFlowFunc(("entered\n"));
    10941095    VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree);
    1095     int rc = usbsysfsEnumerateHostDevicesWorker(pcszDevicesRoot, pvecDevInfo, &vecpchDevs);
     1096    int rc = usbsysfsEnumerateHostDevicesWorker(pszDevicesRoot, pvecDevInfo, &vecpchDevs);
    10961097    VEC_CLEANUP_PTR(&vecpchDevs);
    10971098    LogFlowFunc(("rc=%Rrc\n", rc));
     
    13901391 * USBProxyService::getDevices() implementation for sysfs.
    13911392 */
    1392 static PUSBDEVICE usbsysfsGetDevices(const char *pcszDevicesRoot, bool testfs)
     1393static PUSBDEVICE usbsysfsGetDevices(const char *pszDevicesRoot, bool fUnsupportedDevicesToo)
    13931394{
    13941395    /* Add each of the devices found to the chain. */
     
    14001401
    14011402    VEC_INIT_OBJ(&vecDevInfo, USBDeviceInfo, usbsysfsCleanupDevInfo);
    1402     rc = usbsysfsEnumerateHostDevices(pcszDevicesRoot, &vecDevInfo);
     1403    rc = usbsysfsEnumerateHostDevices(pszDevicesRoot, &vecDevInfo);
    14031404    if (RT_FAILURE(rc))
    14041405        return NULL;
     
    14121413        if (   RT_SUCCESS(rc)
    14131414            && (   pDev->enmState != USBDEVICESTATE_UNSUPPORTED
    1414                 || testfs)
     1415                || fUnsupportedDevicesToo)
    14151416            && pDev->pszAddress != NULL
    14161417           )
     
    14481449static void *testDLSym(void *handle, const char *symbol)
    14491450{
     1451    RT_NOREF(handle, symbol);
    14501452    Assert(handle == RTLD_DEFAULT);
    14511453    Assert(!RTStrCmp(symbol, "inotify_init"));
     
    14941496static const char **g_papszUsbfsDeviceAddresses = NULL;
    14951497
    1496 static PUSBDEVICE testGetUsbfsDevices(const char *pcszUsbfsRoot, bool testfs)
    1497 {
    1498     const char **pcsz;
     1498static PUSBDEVICE testGetUsbfsDevices(const char *pszUsbfsRoot, bool fUnsupportedDevicesToo)
     1499{
     1500    RT_NOREF(pszUsbfsRoot, fUnsupportedDevicesToo);
     1501    const char **psz;
    14991502    PUSBDEVICE pList = NULL, pTail = NULL;
    1500     for (pcsz = g_papszUsbfsDeviceAddresses; pcsz && *pcsz; ++pcsz)
     1503    for (psz = g_papszUsbfsDeviceAddresses; psz && *psz; ++psz)
    15011504    {
    15021505        PUSBDEVICE pNext = (PUSBDEVICE)RTMemAllocZ(sizeof(USBDEVICE));
    15031506        if (pNext)
    1504             pNext->pszAddress = RTStrDup(*pcsz);
     1507            pNext->pszAddress = RTStrDup(*psz);
    15051508        if (!pNext || !pNext->pszAddress)
    15061509        {
     
    15341537static const char **g_papszAccessibleFiles = NULL;
    15351538
    1536 static int testAccess(const char *pcszPath, int mode)
    1537 {
    1538     const char **pcsz;
    1539     for (pcsz = g_papszAccessibleFiles; pcsz && *pcsz; ++pcsz)
    1540         if (!RTStrCmp(pcszPath, *pcsz))
     1539static int testAccess(const char *pszPath, int mode)
     1540{
     1541    RT_NOREF(mode);
     1542    const char **psz;
     1543    for (psz = g_papszAccessibleFiles; psz && *psz; ++psz)
     1544        if (!RTStrCmp(pszPath, *psz))
    15411545            return 0;
    15421546    return -1;
     
    15591563
    15601564/** The path we pretend the usbfs root is located at, or NULL. */
    1561 const char *s_pcszTestUsbfsRoot;
     1565const char *s_pszTestUsbfsRoot;
    15621566/** Should usbfs be accessible to the current user? */
    15631567bool s_fTestUsbfsAccessible;
    15641568/** The path we pretend the device node tree root is located at, or NULL. */
    1565 const char *s_pcszTestDevicesRoot;
     1569const char *s_pszTestDevicesRoot;
    15661570/** Should the device node tree be accessible to the current user? */
    15671571bool s_fTestDevicesAccessible;
     
    15691573int s_rcTestMethodInitResult;
    15701574/** The value of the VBOX_USB environment variable. */
    1571 const char *s_pcszTestEnvUsb;
     1575const char *s_pszTestEnvUsb;
    15721576/** The value of the VBOX_USB_ROOT environment variable. */
    1573 const char *s_pcszTestEnvUsbRoot;
     1577const char *s_pszTestEnvUsbRoot;
    15741578
    15751579
     
    15771581 * during unit testing, and (hack!) what return code it will see from
    15781582 * the access method-specific initialisation. */
    1579 void TestUSBSetupInit(const char *pcszUsbfsRoot, bool fUsbfsAccessible,
    1580                       const char *pcszDevicesRoot, bool fDevicesAccessible,
     1583void TestUSBSetupInit(const char *pszUsbfsRoot, bool fUsbfsAccessible,
     1584                      const char *pszDevicesRoot, bool fDevicesAccessible,
    15811585                      int rcMethodInitResult)
    15821586{
    1583     s_pcszTestUsbfsRoot = pcszUsbfsRoot;
     1587    s_pszTestUsbfsRoot = pszUsbfsRoot;
    15841588    s_fTestUsbfsAccessible = fUsbfsAccessible;
    1585     s_pcszTestDevicesRoot = pcszDevicesRoot;
     1589    s_pszTestDevicesRoot = pszDevicesRoot;
    15861590    s_fTestDevicesAccessible = fDevicesAccessible;
    15871591    s_rcTestMethodInitResult = rcMethodInitResult;
     
    15911595/** Specify the environment that the @a init method will see during unit
    15921596 * testing. */
    1593 void TestUSBSetEnv(const char *pcszEnvUsb, const char *pcszEnvUsbRoot)
    1594 {
    1595     s_pcszTestEnvUsb = pcszEnvUsb;
    1596     s_pcszTestEnvUsbRoot = pcszEnvUsbRoot;
     1597void TestUSBSetEnv(const char *pszEnvUsb, const char *pszEnvUsbRoot)
     1598{
     1599    s_pszTestEnvUsb = pszEnvUsb;
     1600    s_pszTestEnvUsbRoot = pszEnvUsbRoot;
    15971601}
    15981602
     
    16001604 * return test values. */
    16011605# define RTEnvGet(a) \
    1602     (  !RTStrCmp(a, "VBOX_USB") ? s_pcszTestEnvUsb \
    1603      : !RTStrCmp(a, "VBOX_USB_ROOT") ? s_pcszTestEnvUsbRoot \
     1606    (  !RTStrCmp(a, "VBOX_USB") ? s_pszTestEnvUsb \
     1607     : !RTStrCmp(a, "VBOX_USB_ROOT") ? s_pszTestEnvUsbRoot \
    16041608     : NULL)
    1605 # define USBProxyLinuxCheckDeviceRoot(pcszPath, fUseNodes) \
     1609# define USBProxyLinuxCheckDeviceRoot(pszPath, fUseNodes) \
    16061610    (   ((fUseNodes) && s_fTestDevicesAccessible \
    1607          && !RTStrCmp(pcszPath, s_pcszTestDevicesRoot)) \
     1611         && !RTStrCmp(pszPath, s_pszTestDevicesRoot)) \
    16081612     || (!(fUseNodes) && s_fTestUsbfsAccessible \
    1609          && !RTStrCmp(pcszPath, s_pcszTestUsbfsRoot)))
    1610 # define RTDirExists(pcszDir) \
    1611     (   (pcszDir) \
    1612      && (   !RTStrCmp(pcszDir, s_pcszTestDevicesRoot) \
    1613          || !RTStrCmp(pcszDir, s_pcszTestUsbfsRoot)))
    1614 # define RTFileExists(pcszFile) \
    1615     (   (pcszFile) \
    1616      && s_pcszTestUsbfsRoot \
    1617      && !RTStrNCmp(pcszFile, s_pcszTestUsbfsRoot, strlen(s_pcszTestUsbfsRoot)) \
    1618      && !RTStrCmp(pcszFile + strlen(s_pcszTestUsbfsRoot), "/devices"))
     1613         && !RTStrCmp(pszPath, s_pszTestUsbfsRoot)))
     1614# define RTDirExists(pszDir) \
     1615    (   (pszDir) \
     1616     && (   !RTStrCmp(pszDir, s_pszTestDevicesRoot) \
     1617         || !RTStrCmp(pszDir, s_pszTestUsbfsRoot)))
     1618# define RTFileExists(pszFile) \
     1619    (   (pszFile) \
     1620     && s_pszTestUsbfsRoot \
     1621     && !RTStrNCmp(pszFile, s_pszTestUsbfsRoot, strlen(s_pszTestUsbfsRoot)) \
     1622     && !RTStrCmp(pszFile + strlen(s_pszTestUsbfsRoot), "/devices"))
    16191623
    16201624#endif /* UNIT_TEST */
     
    16311635 *                              the prefered access method is USBFS-like and to
    16321636 *                              false if it is sysfs/device node-like
    1633  * @param  ppcszDevicesRoot     on success the root of the tree of USBFS-like
     1637 * @param  ppszDevicesRoot     on success the root of the tree of USBFS-like
    16341638 *                              device nodes will be stored here
    16351639 */
    1636 int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **ppcszDevicesRoot)
     1640int USBProxyLinuxChooseMethod(bool *pfUsingUsbfsDevices, const char **ppszDevicesRoot)
    16371641{
    16381642    /*
     
    16471651    bool fUsbfsChosen = false;
    16481652    bool fSysfsChosen = false;
    1649     const char *pcszUsbFromEnv = RTEnvGet("VBOX_USB");
    1650     const char *pcszUsbRoot = NULL;
    1651     if (pcszUsbFromEnv)
     1653    const char *pszUsbFromEnv = RTEnvGet("VBOX_USB");
     1654    const char *pszUsbRoot = NULL;
     1655    if (pszUsbFromEnv)
    16521656    {
    16531657        bool fValidVBoxUSB = true;
    16541658
    1655         pcszUsbRoot = RTEnvGet("VBOX_USB_ROOT");
    1656         if (!RTStrICmp(pcszUsbFromEnv, "USBFS"))
     1659        pszUsbRoot = RTEnvGet("VBOX_USB_ROOT");
     1660        if (!RTStrICmp(pszUsbFromEnv, "USBFS"))
    16571661        {
    16581662            LogRel(("Default USB access method set to \"usbfs\" from environment\n"));
    16591663            fUsbfsChosen = true;
    16601664        }
    1661         else if (!RTStrICmp(pcszUsbFromEnv, "SYSFS"))
     1665        else if (!RTStrICmp(pszUsbFromEnv, "SYSFS"))
    16621666        {
    16631667            LogRel(("Default USB method set to \"sysfs\" from environment\n"));
     
    16661670        else
    16671671        {
    1668             LogRel(("Invalid VBOX_USB environment variable setting \"%s\"\n", pcszUsbFromEnv));
     1672            LogRel(("Invalid VBOX_USB environment variable setting \"%s\"\n", pszUsbFromEnv));
    16691673            fValidVBoxUSB = false;
    1670             pcszUsbFromEnv = NULL;
    1671         }
    1672         if (!fValidVBoxUSB && pcszUsbRoot)
    1673             pcszUsbRoot = NULL;
    1674     }
    1675     if (!pcszUsbRoot)
     1674            pszUsbFromEnv = NULL;
     1675        }
     1676        if (!fValidVBoxUSB && pszUsbRoot)
     1677            pszUsbRoot = NULL;
     1678    }
     1679    if (!pszUsbRoot)
    16761680    {
    16771681        if (   !fUsbfsChosen
     
    16791683        {
    16801684            fSysfsChosen = true;
    1681             pcszUsbRoot = "/dev/vboxusb";
     1685            pszUsbRoot = "/dev/vboxusb";
    16821686        }
    16831687        else if (   !fSysfsChosen
     
    16851689        {
    16861690            fUsbfsChosen = true;
    1687             pcszUsbRoot = "/proc/bus/usb";
    1688         }
    1689     }
    1690     else if (!USBProxyLinuxCheckDeviceRoot(pcszUsbRoot, fSysfsChosen))
    1691         pcszUsbRoot = NULL;
    1692     if (pcszUsbRoot)
     1691            pszUsbRoot = "/proc/bus/usb";
     1692        }
     1693    }
     1694    else if (!USBProxyLinuxCheckDeviceRoot(pszUsbRoot, fSysfsChosen))
     1695        pszUsbRoot = NULL;
     1696    if (pszUsbRoot)
    16931697    {
    16941698        *pfUsingUsbfsDevices = fUsbfsChosen;
    1695         *ppcszDevicesRoot = pcszUsbRoot;
     1699        *ppszDevicesRoot = pszUsbRoot;
    16961700        return VINF_SUCCESS;
    16971701    }
    16981702    /* else */
    1699     return pcszUsbFromEnv ? VERR_NOT_FOUND
     1703    return pszUsbFromEnv ? VERR_NOT_FOUND
    17001704         : RTDirExists("/dev/vboxusb") ? VERR_VUSB_USB_DEVICE_PERMISSION
    17011705         : RTFileExists("/proc/bus/usb/devices") ? VERR_VUSB_USBFS_PERMISSION
     
    17131717 * Check whether a USB device tree root is usable.
    17141718 *
    1715  * @param pcszRoot        the path to the root of the device tree
     1719 * @param pszRoot        the path to the root of the device tree
    17161720 * @param fIsDeviceNodes  whether this is a device node (or usbfs) tree
    17171721 * @note  returns a pointer into a static array so it will stay valid
    17181722 */
    1719 bool USBProxyLinuxCheckDeviceRoot(const char *pcszRoot, bool fIsDeviceNodes)
     1723bool USBProxyLinuxCheckDeviceRoot(const char *pszRoot, bool fIsDeviceNodes)
    17201724{
    17211725    bool fOK = false;
     
    17231727    {
    17241728#ifdef VBOX_USB_WITH_USBFS
    1725         if (!access(pcszRoot, R_OK | X_OK))
     1729        if (!access(pszRoot, R_OK | X_OK))
    17261730        {
    17271731            fOK = true;
    1728             PUSBDEVICE pDevices = usbfsGetDevices(pcszRoot, true);
     1732            PUSBDEVICE pDevices = usbfsGetDevices(pszRoot, true);
    17291733            if (pDevices)
    17301734            {
     
    17401744#ifdef VBOX_USB_WITH_SYSFS
    17411745    /* device nodes */
    1742     else if (usbsysfsInotifyAvailable() && !access(pcszRoot, R_OK | X_OK))
     1746    else if (usbsysfsInotifyAvailable() && !access(pszRoot, R_OK | X_OK))
    17431747        fOK = true;
    17441748#endif
     
    17561760 * Result should be freed using #deviceFree or something equivalent.
    17571761 *
    1758  * @param pcszDevicesRoot  the path to the root of the device tree
     1762 * @param pszDevicesRoot  the path to the root of the device tree
    17591763 * @param fUseSysfs        whether to use sysfs (or usbfs) for enumeration
    17601764 */
    1761 PUSBDEVICE USBProxyLinuxGetDevices(const char *pcszDevicesRoot, bool fUseSysfs)
     1765PUSBDEVICE USBProxyLinuxGetDevices(const char *pszDevicesRoot, bool fUseSysfs)
    17621766{
    17631767    if (!fUseSysfs)
    17641768    {
    17651769#ifdef VBOX_USB_WITH_USBFS
    1766         return usbfsGetDevices(pcszDevicesRoot, false);
     1770        return usbfsGetDevices(pszDevicesRoot, false);
    17671771#else
    17681772        return NULL;
     
    17711775
    17721776#ifdef VBOX_USB_WITH_SYSFS
    1773     return usbsysfsGetDevices(pcszDevicesRoot, false);
     1777    return usbsysfsGetDevices(pszDevicesRoot, false);
    17741778#else
    17751779    return NULL;
  • trunk/src/VBox/Main/src-server/xpcom/server_module.cpp

    r62485 r63378  
    175175
    176176    nsresult rc = NS_OK;
    177     int vrc = VINF_SUCCESS;
    178177
    179178    do
     
    312311    while (0);
    313312
    314     LogFlowFunc(("rc=%Rhrc (%#08x), vrc=%Rrc\n", rc, rc, vrc));
     313    LogFlowFunc(("rc=%Rhrc (%#08x)\n", rc, rc));
    315314    LogFlowFuncLeave();
    316315
  • trunk/src/VBox/Main/testcase/tstAPI.cpp

    r60063 r63378  
    4444///////////////////////////////////////////////////////////////////////////////
    4545
    46 static Bstr getObjectName(ComPtr<IVirtualBox> aVirtualBox,
    47                                   ComPtr<IUnknown> aObject);
     46#ifdef VBOX_WITH_RESOURCE_USAGE_API
     47static Bstr getObjectName(ComPtr<IVirtualBox> aVirtualBox, ComPtr<IUnknown> aObject);
    4848static void queryMetrics(ComPtr<IVirtualBox> aVirtualBox,
    4949                         ComPtr<IPerformanceCollector> collector,
     
    5151static void listAffectedMetrics(ComPtr<IVirtualBox> aVirtualBox,
    5252                                ComSafeArrayIn(IPerformanceMetric*, aMetrics));
     53#endif
    5354
    5455// funcs
     
    15961597
    15971598#ifdef VBOX_WITH_RESOURCE_USAGE_API
     1599
    15981600static void queryMetrics(ComPtr<IVirtualBox> aVirtualBox,
    15991601                         ComPtr<IPerformanceCollector> collector,
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