VirtualBox

Changeset 11176

Show
Ignore:
Timestamp:
08/06/08 13:07:08 (4 months ago)
Author:
vboxsync
Message:

VBoxHDD-new: VDGetInterface* has a pointer to the interface descriptor now instead of the opaque pointer to the callback table - better type checking during compilation which reduces mistakes

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/VBoxHDD-new.h

    r11048 r11176  
    366366 * 
    367367 * @return Pointer to the callback table. 
    368  * @param  pCallbacks Opaque interface pointer. 
    369  */ 
    370 DECLINLINE(PVDINTERFACEERROR) VDGetInterfaceError(void *pCallbacks) 
    371 
    372     PVDINTERFACEERROR pInterfaceError = (PVDINTERFACEERROR)pCallbacks; 
     368 * @param  pInterface Pointer to the interface descriptor. 
     369 */ 
     370DECLINLINE(PVDINTERFACEERROR) VDGetInterfaceError(PVDINTERFACE pInterface) 
     371
     372    /* Check that the interface descriptor is a error interface. */ 
     373    AssertMsgReturn(   (pInterface->enmInterface == VDINTERFACETYPE_ERROR) 
     374                    && (pInterface->cbSize == sizeof(VDINTERFACE)), 
     375                    ("Not an error interface"), NULL); 
     376 
     377    PVDINTERFACEERROR pInterfaceError = (PVDINTERFACEERROR)pInterface->pCallbacks; 
    373378 
    374379    /* Do basic checks. */ 
    375380    AssertMsgReturn(   (pInterfaceError->cbSize == sizeof(VDINTERFACEERROR)) 
    376381                    && (pInterfaceError->enmInterface == VDINTERFACETYPE_ERROR), 
    377                     ("Not an error interface\n"), NULL); 
     382                    ("A non error callback table attached to a error interface descriptor\n"), NULL); 
    378383 
    379384    return pInterfaceError; 
     
    512517 * 
    513518 * @return Pointer to the callback table. 
    514  * @param  pCallbacks Opaque interface pointer. 
    515  */ 
    516 DECLINLINE(PVDINTERFACEASYNCIO) VDGetInterfaceAsyncIO(void *pCallbacks) 
    517 
    518     PVDINTERFACEASYNCIO pInterfaceAsyncIO = (PVDINTERFACEASYNCIO)pCallbacks; 
     519 * @param  pInterface Pointer to the interface descriptor. 
     520 */ 
     521DECLINLINE(PVDINTERFACEASYNCIO) VDGetInterfaceAsyncIO(PVDINTERFACE pInterface) 
     522
     523    /* Check that the interface descriptor is a async I/O interface. */ 
     524    AssertMsgReturn(   (pInterface->enmInterface == VDINTERFACETYPE_ASYNCIO) 
     525                    && (pInterface->cbSize == sizeof(VDINTERFACE)), 
     526                    ("Not an async I/O interface"), NULL); 
     527 
     528    PVDINTERFACEASYNCIO pInterfaceAsyncIO = (PVDINTERFACEASYNCIO)pInterface->pCallbacks; 
    519529 
    520530    /* Do basic checks. */ 
    521531    AssertMsgReturn(   (pInterfaceAsyncIO->cbSize == sizeof(VDINTERFACEASYNCIO)) 
    522532                    && (pInterfaceAsyncIO->enmInterface == VDINTERFACETYPE_ASYNCIO), 
    523                     ("Not an async I/O interface\n"), NULL); 
     533                    ("A non async I/O callback table attached to a async I/O interface descriptor\n"), NULL); 
    524534 
    525535    return pInterfaceAsyncIO; 
     
    551561 * 
    552562 * @return Pointer to the callback table. 
    553  * @param  pCallbacks Opaque interface pointer. 
    554  */ 
    555 DECLINLINE(PVDINTERFACEPROGRESS) VDGetInterfaceProgress(void *pCallbacks) 
    556 
    557     PVDINTERFACEPROGRESS pInterfaceProgress = (PVDINTERFACEPROGRESS)pCallbacks; 
     563 * @param  pInterface Pointer to the interface descriptor. 
     564 */ 
     565DECLINLINE(PVDINTERFACEPROGRESS) VDGetInterfaceProgress(PVDINTERFACE pInterface) 
     566
     567    /* Check that the interface descriptor is a progress interface. */ 
     568    AssertMsgReturn(   (pInterface->enmInterface == VDINTERFACETYPE_PROGRESS) 
     569                    && (pInterface->cbSize == sizeof(VDINTERFACE)), 
     570                    ("Not a progress interface"), NULL); 
     571 
     572 
     573    PVDINTERFACEPROGRESS pInterfaceProgress = (PVDINTERFACEPROGRESS)pInterface->pCallbacks; 
    558574 
    559575    /* Do basic checks. */ 
    560576    AssertMsgReturn(   (pInterfaceProgress->cbSize == sizeof(VDINTERFACEPROGRESS)) 
    561577                    && (pInterfaceProgress->enmInterface == VDINTERFACETYPE_PROGRESS), 
    562                     ("Not a progress notification interface\n"), NULL); 
     578                    ("A non progress callback table attached to a progress interface descriptor\n"), NULL); 
    563579 
    564580    return pInterfaceProgress; 
     
    621637 * 
    622638 * @return Pointer to the callback table. 
    623  * @param  pCallbacks Opaque interface pointer. 
    624  */ 
    625 DECLINLINE(PVDINTERFACECONFIG) VDGetInterfaceConfig(void *pCallbacks) 
    626 
    627     PVDINTERFACECONFIG pInterfaceConfig = (PVDINTERFACECONFIG)pCallbacks; 
     639 * @param  pInterface Pointer to the interface descriptor. 
     640 */ 
     641DECLINLINE(PVDINTERFACECONFIG) VDGetInterfaceConfig(PVDINTERFACE pInterface) 
     642
     643    /* Check that the interface descriptor is a progress interface. */ 
     644    AssertMsgReturn(   (pInterface->enmInterface == VDINTERFACETYPE_CONFIG) 
     645                    && (pInterface->cbSize == sizeof(VDINTERFACE)), 
     646                    ("Not a config interface"), NULL); 
     647 
     648    PVDINTERFACECONFIG pInterfaceConfig = (PVDINTERFACECONFIG)pInterface->pCallbacks; 
    628649 
    629650    /* Do basic checks. */ 
    630651    AssertMsgReturn(   (pInterfaceConfig->cbSize == sizeof(VDINTERFACECONFIG)) 
    631652                    && (pInterfaceConfig->enmInterface == VDINTERFACETYPE_CONFIG), 
    632                     ("Not a configuration informaion interface\n"), NULL); 
     653                    ("A non config callback table attached to a config interface descriptor\n"), NULL); 
    633654 
    634655    return pInterfaceConfig; 
  • trunk/src/VBox/Devices/Storage/RawHDDCore.cpp

    r11175 r11176  
    343343    pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    344344    if (pImage->pInterfaceError) 
    345         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError->pCallbacks); 
     345        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); 
    346346 
    347347    rc = rawOpenImage(pImage, uOpenFlags); 
     
    398398    pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    399399    if (pImage->pInterfaceError) 
    400         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError->pCallbacks); 
     400        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); 
    401401 
    402402 
  • trunk/src/VBox/Devices/Storage/VBoxHDD-new.cpp

    r10715 r11176  
    817817            pDisk->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    818818            if (pDisk->pInterfaceError) 
    819                 pDisk->pInterfaceErrorCallbacks = VDGetInterfaceError(pDisk->pInterfaceError->pCallbacks); 
     819                pDisk->pInterfaceErrorCallbacks = VDGetInterfaceError(pDisk->pInterfaceError); 
    820820            *ppDisk = pDisk; 
    821821        } 
  • trunk/src/VBox/Devices/Storage/VDIHDDCore.cpp

    r10781 r11176  
    784784    pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    785785    if (pImage->pInterfaceError) 
    786         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError->pCallbacks); 
     786        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); 
    787787 
    788788    rc = vdiOpenImage(pImage, uOpenFlags); 
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r11175 r11176  
    37243724    pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    37253725    if (pImage->pInterfaceError) 
    3726         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError->pCallbacks); 
     3726        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); 
    37273727 
    37283728    /* Try to get async I/O interface. */ 
    37293729    pImage->pInterfaceAsyncIO = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ASYNCIO); 
    37303730    if (pImage->pInterfaceAsyncIO) 
    3731         pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO->pCallbacks); 
     3731        pImage->pInterfaceAsyncIOCallbacks = VDGetInterfaceAsyncIO(pImage->pInterfaceAsyncIO); 
    37323732 
    37333733 
     
    38043804    pImage->pInterfaceError = VDGetInterfaceFromList(pInterfaces, VDINTERFACETYPE_ERROR); 
    38053805    if (pImage->pInterfaceError) 
    3806         pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError->pCallbacks); 
     3806        pImage->pInterfaceErrorCallbacks = VDGetInterfaceError(pImage->pInterfaceError); 
    38073807 
    38083808    rc = vmdkCreateImage(pImage, enmType, cbSize, uImageFlags, pszComment, 

© 2008 Sun Microsystems, Inc.
ContactPrivacy policy