VirtualBox

忽略:
時間撮記:
2014-4-17 上午09:29:40 (11 年 以前)
作者:
vboxsync
訊息:

Main: use RT_FROM_MEMBER instead of RT_OFFSETOF; some Assert* cleanup

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/Main/src-client/VMMDevInterface.cpp

    r51092 r51096  
    7474} DRVMAINVMMDEV, *PDRVMAINVMMDEV;
    7575
    76 /** Converts PDMIVMMDEVCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
    77 #define PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, Connector)) )
    78 
    79 #ifdef VBOX_WITH_HGCM
    80 /** Converts PDMIHGCMCONNECTOR pointer to a DRVMAINVMMDEV pointer. */
    81 #define PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface) ( (PDRVMAINVMMDEV) ((uintptr_t)pInterface - RT_OFFSETOF(DRVMAINVMMDEV, HGCMConnector)) )
    82 #endif
    83 
    8476//
    8577// constructor / destructor
     
    164156                                           uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS)
    165157{
    166     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     158    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    167159    Console *pConsole = pDrv->pVMMDev->getParent();
    168160
    169161    /* Store that information in IGuest */
    170162    Guest* guest = pConsole->getGuest();
    171     Assert(guest);
    172     if (!guest)
    173         return;
     163    AssertPtrReturnVoid(guest);
    174164
    175165    guest->setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS);
     
    186176                                              const uint8_t *puDetails, uint32_t cbDetails)
    187177{
    188     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     178    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    189179    AssertPtr(pDrv);
    190180    Console *pConsole = pDrv->pVMMDev->getParent();
     
    193183    /* Store that information in IGuest. */
    194184    Guest* pGuest = pConsole->getGuest();
    195     AssertPtr(pGuest);
    196     if (!pGuest)
    197         return;
     185    AssertPtrReturnVoid(pGuest);
    198186
    199187    pGuest->onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState,
     
    214202DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo)
    215203{
    216     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
    217 
    218     Assert(guestInfo);
    219     if (!guestInfo)
    220         return;
    221 
     204    AssertPtrReturnVoid(guestInfo);
     205   
     206    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    222207    Console *pConsole = pDrv->pVMMDev->getParent();
    223208
    224209    /* Store that information in IGuest */
    225210    Guest* guest = pConsole->getGuest();
    226     Assert(guest);
    227     if (!guest)
    228         return;
     211    AssertPtrReturnVoid(guest);
    229212
    230213    if (guestInfo->interfaceVersion != 0)
     
    266249                                          const char *pszName, uint32_t uRevision, uint32_t fFeatures)
    267250{
    268     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     251    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    269252    AssertPtr(pszName);
    270253    Assert(uFullVersion);
     
    272255    /* Store that information in IGuest. */
    273256    Guest *pGuest = pDrv->pVMMDev->getParent()->getGuest();
    274     Assert(pGuest);
    275     if (!pGuest)
    276         return;
     257    AssertPtrReturnVoid(pGuest);
    277258
    278259    /* Just pass it on... */
     
    297278DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities)
    298279{
    299     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     280    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    300281    AssertPtr(pDrv);
    301282    Console *pConsole = pDrv->pVMMDev->getParent();
     
    303284    /* store that information in IGuest */
    304285    Guest* pGuest = pConsole->getGuest();
    305     AssertPtr(pGuest);
    306     if (!pGuest)
    307         return;
     286    AssertPtrReturnVoid(pGuest);
    308287
    309288    /*
     
    330309DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps)
    331310{
    332     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     311    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    333312    Console *pConsole = pDrv->pVMMDev->getParent();
    334313
     
    363342                                            void *pShape)
    364343{
    365     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     344    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    366345    Console *pConsole = pDrv->pVMMDev->getParent();
    367346
     
    382361DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory)
    383362{
    384     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     363    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    385364    Console *pConsole = pDrv->pVMMDev->getParent();
    386365
     
    397376DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface)
    398377{
    399     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     378    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    400379    Console *pConsole = pDrv->pVMMDev->getParent();
    401380
     
    412391                                           uint32_t bpp, bool *fSupported)
    413392{
    414     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     393    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    415394    Console *pConsole = pDrv->pVMMDev->getParent();
    416395
     
    441420DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction)
    442421{
    443     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     422    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    444423    Console *pConsole = pDrv->pVMMDev->getParent();
    445424
     
    456435DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags)
    457436{
    458     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     437    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    459438
    460439    if (pDrv->pVMMDev)
     
    466445DECLCALLBACK(int) vmmdevSetVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t cRect, PRTRECT pRect)
    467446{
    468     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     447    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    469448    Console *pConsole = pDrv->pVMMDev->getParent();
    470449
     
    477456DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect)
    478457{
    479     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     458    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    480459    Console *pConsole = pDrv->pVMMDev->getParent();
    481460
     
    496475DECLCALLBACK(int) vmmdevQueryStatisticsInterval(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pulInterval)
    497476{
    498     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     477    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    499478    Console *pConsole = pDrv->pVMMDev->getParent();
    500479    ULONG          val = 0;
     
    505484    /* store that information in IGuest */
    506485    Guest* guest = pConsole->getGuest();
    507     Assert(guest);
    508     if (!guest)
    509         return VERR_GENERAL_FAILURE;
     486    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
    510487
    511488    guest->COMGETTER(StatisticsUpdateInterval)(&val);
     
    524501DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon)
    525502{
    526     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     503    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    527504    Console *pConsole = pDrv->pVMMDev->getParent();
    528505    ULONG          val = 0;
     
    533510    /* store that information in IGuest */
    534511    Guest* guest = pConsole->getGuest();
    535     Assert(guest);
    536     if (!guest)
    537         return VERR_GENERAL_FAILURE;
     512    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
    538513
    539514    guest->COMGETTER(MemoryBalloonSize)(&val);
     
    552527DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled)
    553528{
    554     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
     529    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
    555530    Console *pConsole = pDrv->pVMMDev->getParent();
    556531    BOOL           val = 0;
     
    561536    /* store that information in IGuest */
    562537    Guest* guest = pConsole->getGuest();
    563     Assert(guest);
    564     if (!guest)
    565         return VERR_GENERAL_FAILURE;
     538    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
    566539
    567540    *pfPageFusionEnabled = !!guest->isPageFusionEnabled();
     
    579552DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats)
    580553{
    581     PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface);
    582     Console *pConsole = pDrv->pVMMDev->getParent();
    583 
    584     Assert(pGuestStats);
    585     if (!pGuestStats)
    586         return VERR_INVALID_POINTER;
     554    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, Connector);
     555    Console *pConsole = pDrv->pVMMDev->getParent();
     556
     557    AssertPtrReturn(pGuestStats, VERR_INVALID_POINTER);
    587558
    588559    /* store that information in IGuest */
    589560    Guest* guest = pConsole->getGuest();
    590     Assert(guest);
    591     if (!guest)
    592         return VERR_GENERAL_FAILURE;
     561    AssertPtrReturn(guest, VERR_GENERAL_FAILURE);
    593562
    594563    if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
     
    633602    LogSunlover(("Enter\n"));
    634603
    635     PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
     604    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
    636605
    637606    if (    !pServiceLocation
     
    652621    LogSunlover(("Enter\n"));
    653622
    654     PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
     623    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
    655624
    656625    if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
     
    665634    LogSunlover(("Enter\n"));
    666635
    667     PDRVMAINVMMDEV pDrv = PDMIHGCMCONNECTOR_2_MAINVMMDEV(pInterface);
     636    PDRVMAINVMMDEV pDrv = RT_FROM_MEMBER(pInterface, DRVMAINVMMDEV, HGCMConnector);
    668637
    669638    if (!pDrv->pVMMDev || !pDrv->pVMMDev->hgcmIsActive())
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette