VirtualBox

Changeset 32262 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Sep 6, 2010 11:37:00 PM (14 years ago)
Author:
vboxsync
Message:

Main/linux/vector container: simplification

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/HostHardwareLinux.h

    r32258 r32262  
    142142
    143143/** Constructor */
    144 static inline int VBoxMainUSBDevInfoInit(VBoxMainUSBDeviceInfo *pSelf)
    145 {
    146     return VEC_INIT_OBJ(&pSelf->mvecDevInfo, USBDeviceInfo, USBDevInfoCleanup);
     144static inline void VBoxMainUSBDevInfoInit(VBoxMainUSBDeviceInfo *pSelf)
     145{
     146    VEC_INIT_OBJ(&pSelf->mvecDevInfo, USBDeviceInfo, USBDevInfoCleanup);
    147147}
    148148
  • trunk/src/VBox/Main/include/vector.h

    r32258 r32262  
    163163    pvec->muTypeHash = uTypeHash; \
    164164    pvec->mpfnCleanup = pfnCleanup ? pfnCleanup : vecNoCleanup; \
    165     pvec->mpvaElements = NULL; \
    166     return VEC_EXPAND(pvec);
     165    pvec->mpvaElements = NULL;
    167166
    168167/** Initialise a vector. */
    169 DECLINLINE(int) vecInitObj(VECTOR_OBJ *pvec, size_t cbElement,
    170                              unsigned uTypeHash, void (*pfnCleanup)(void *))
     168DECLINLINE(void) vecInitObj(VECTOR_OBJ *pvec, size_t cbElement,
     169                            unsigned uTypeHash, void (*pfnCleanup)(void *))
    171170{
    172171    VEC_INIT(pvec, cbElement, uTypeHash, pfnCleanup)
     
    174173
    175174/** Initialise a pointer vector. */
    176 DECLINLINE(int) vecInitPtr(VECTOR_PTR *pvec, size_t cbElement,
    177                              unsigned uTypeHash, void (*pfnCleanup)(void *))
     175DECLINLINE(void) vecInitPtr(VECTOR_PTR *pvec, size_t cbElement,
     176                            unsigned uTypeHash, void (*pfnCleanup)(void *))
    178177{
    179178    VEC_INIT(pvec, cbElement, uTypeHash, pfnCleanup)
     
    212211
    213212/**
    214  * Initialise a vector structure.
    215  * @returns iprt status code (VINF_SUCCESS or VERR_NO_MEMORY)
     213 * Initialise a vector structure.  Always succeeds.
    216214 * @param   pvec        pointer to an uninitialised vector structure
    217215 * @param   type        the type of the objects in the vector.  As this is
     
    227225
    228226/**
    229  * Initialise a vector-of-pointers structure.
    230  * @returns iprt status code (VINF_SUCCESS or VERR_NO_MEMORY)
     227 * Initialise a vector-of-pointers structure.  Always succeeds.
    231228 * @param   pvec        pointer to an uninitialised vector structure
    232229 * @param   type        the type of the pointers in the vector, including the
  • trunk/src/VBox/Main/linux/HostHardwareLinux.cpp

    r32261 r32262  
    13231323
    13241324    AssertRCReturn(mStatus, VERR_WRONG_ORDER);
    1325     if (RT_FAILURE(rc = VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree)))
    1326         return rc;
    13271325    bool fEntered = ASMAtomicCmpXchgU32(&mfWaiting, 1, 0);
    1328     if (!fEntered)
    1329         VEC_CLEANUP_PTR(&vecpchDevs);
    13301326    AssertReturn(fEntered, VERR_WRONG_ORDER);
     1327    VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree);
    13311328    do {
    13321329        struct pollfd pollFD[MAX_POLLID];
     
    14181415    pSelf->mDevice = aDevice ? RTStrDup(aDevice) : NULL;
    14191416    pSelf->mSysfsPath = aSystemID ? RTStrDup(aSystemID) : NULL;
    1420     if (   RT_FAILURE(VEC_INIT_PTR(&pSelf->mvecpszInterfaces, char *, RTStrFree))
    1421         || (aDevice && !pSelf->mDevice) || (aSystemID && ! pSelf->mSysfsPath))
     1417    VEC_INIT_PTR(&pSelf->mvecpszInterfaces, char *, RTStrFree);
     1418    if ((aDevice && !pSelf->mDevice) || (aSystemID && ! pSelf->mSysfsPath))
    14221419    {
    14231420        USBDevInfoCleanup(pSelf);
     
    15841581int USBDevInfoUpdateDevices (VBoxMainUSBDeviceInfo *pSelf)
    15851582{
     1583    int rc = VINF_SUCCESS;
     1584
    15861585    LogFlowFunc(("entered\n"));
    15871586    VECTOR_PTR(char *) vecpchDevs;
    1588     int rc = VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree);
    1589     if (RT_FAILURE(rc))
    1590         return rc;
     1587    VEC_INIT_PTR(&vecpchDevs, char *, RTStrFree);
    15911588    VEC_CLEAR_OBJ(&pSelf->mvecDevInfo);
    15921589#ifdef VBOX_USB_WITH_SYSFS
  • trunk/src/VBox/Main/linux/USBProxyServiceLinux.cpp

    r32258 r32262  
    263263
    264264#ifdef VBOX_USB_WITH_SYSFS
    265     int rc2;
    266     if (RT_FAILURE((rc2 = VBoxMainUSBDevInfoInit(&mDeviceList))))
    267         return rc2;
     265    VBoxMainUSBDevInfoInit(&mDeviceList);
    268266    int rc = mWaiter.getStatus();
    269267    if (RT_SUCCESS(rc) || rc == VERR_TIMEOUT || rc == VERR_TRY_AGAIN)
  • trunk/src/VBox/Main/testcase/tstHostHardwareLinux.cpp

    r32258 r32262  
    9292#ifdef VBOX_USB_WITH_SYSFS
    9393    VBoxMainUSBDeviceInfo deviceInfo;
    94     AssertRCReturn(VBoxMainUSBDevInfoInit(&deviceInfo), 1);
     94    VBoxMainUSBDevInfoInit(&deviceInfo);
    9595    rc = USBDevInfoUpdateDevices(&deviceInfo);
    9696    if (RT_FAILURE(rc))
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