VirtualBox

Changeset 64650 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Nov 11, 2016 2:55:07 PM (8 years ago)
Author:
vboxsync
Message:

bugref:8614: Additions/common/VBoxVideo: make the code more self-contained: my last attempt at removing all assertions from debug versions of the Linux video driver was not correct: I missed some places, and forgot that LINUX_VERSION_CODE is only defined when Linux headers are included. Hopefully fix that.

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxVideo/HGSMIBase.cpp

    r64337 r64650  
    4444    HGSMIBUFFERHEADER *pHdr = HGSMIBufferHeaderFromData(pvMem);
    4545    HGSMIOFFSET offMem = HGSMIPointerToOffset(&pCtx->areaCtx, pHdr);
    46     Assert(offMem != HGSMIOFFSET_VOID);
     46    VBVOAssert(offMem != HGSMIOFFSET_VOID);
    4747    if(offMem != HGSMIOFFSET_VOID)
    4848    {
     
    5757{
    5858    int rc = HGSMIBufferProcess(&pCtx->areaCtx, &pCtx->channels, offBuffer);
    59     Assert(!RT_FAILURE(rc));
     59    VBVOAssert(!RT_FAILURE(rc));
    6060    if(RT_FAILURE(rc))
    6161    {
     
    7878{
    7979    HGSMIOFFSET offset = hgsmiGetHostBuffer(pCtx);
    80     AssertReturnVoid(offset != HGSMIOFFSET_VOID);
     80    VBVOAssertReturnVoid(offset != HGSMIOFFSET_VOID);
    8181    hgsmiHostCmdProcess(pCtx, offset);
    8282}
     
    162162    HGSMIOFFSET offBuffer = HGSMIHeapBufferOffset (HGSMIGUESTCMDHEAP_GET(&pCtx->heapCtx), pvBuffer);
    163163
    164     Assert(offBuffer != HGSMIOFFSET_VOID);
     164    VBVOAssert(offBuffer != HGSMIOFFSET_VOID);
    165165    if (offBuffer != HGSMIOFFSET_VOID)
    166166    {
     
    242242        if (RT_SUCCESS(rc))
    243243        {
    244             AssertRC(pCaps->rc);
     244            VBVOAssertRC(pCaps->rc);
    245245            rc = pCaps->rc;
    246246        }
     
    318318                                             uint32_t *poffHostFlags)
    319319{
    320     AssertPtrNullReturnVoid(poffVRAMBaseMapping);
    321     AssertPtrNullReturnVoid(pcbMapping);
    322     AssertPtrNullReturnVoid(poffGuestHeapMemory);
    323     AssertPtrNullReturnVoid(pcbGuestHeapMemory);
    324     AssertPtrNullReturnVoid(poffHostFlags);
     320    VBVOAssertPtrNullReturnVoid(poffVRAMBaseMapping);
     321    VBVOAssertPtrNullReturnVoid(pcbMapping);
     322    VBVOAssertPtrNullReturnVoid(poffGuestHeapMemory);
     323    VBVOAssertPtrNullReturnVoid(pcbGuestHeapMemory);
     324    VBVOAssertPtrNullReturnVoid(poffHostFlags);
    325325    if (poffVRAMBaseMapping)
    326326        *poffVRAMBaseMapping = cbVRAM - VBVA_ADAPTER_INFORMATION_SIZE;
     
    386386    uint32_t offVRAMHostArea = offVRAMBaseMapping, cbHostArea = 0;
    387387
    388     AssertPtrReturnVoid(poffVRAMHostArea);
    389     AssertPtrReturnVoid(pcbHostArea);
     388    VBVOAssertPtrReturnVoid(poffVRAMHostArea);
     389    VBVOAssertPtrReturnVoid(pcbHostArea);
    390390    VBoxQueryConfHGSMI(pCtx, VBOX_VBVA_CONF32_HOST_HEAP_SIZE, &cbHostArea);
    391391    if (cbHostArea != 0)
     
    464464     * host heap is ready */
    465465    int rc = vboxHGSMIReportFlagsLocation(pCtx, offVRAMFlagsLocation);
    466     AssertRC(rc);
     466    VBVOAssertRC(rc);
    467467    if (RT_SUCCESS(rc) && fCaps)
    468468    {
    469469        /* Inform about caps */
    470470        rc = vboxHGSMISendCapsInfo(pCtx, fCaps);
    471         AssertRC(rc);
     471        VBVOAssertRC(rc);
    472472    }
    473473    if (RT_SUCCESS (rc))
     
    475475        /* Report the host heap location. */
    476476        rc = vboxHGSMIReportHostArea(pCtx, offVRAMHostArea, cbHostArea);
    477         AssertRC(rc);
     477        VBVOAssertRC(rc);
    478478    }
    479479    // Log(("VBoxVideo::vboxSetupAdapterInfo finished rc = %d\n", rc));
  • trunk/src/VBox/Additions/common/VBoxVideo/Modesetting.cpp

    r64425 r64650  
    2323#ifndef VBOX_GUESTR3XF86MOD
    2424# include <iprt/string.h>
    25 #endif
    26 
    27 #ifndef LINUX_VERSION_CODE
    28 # define VBVOAssertPtr AssertPtr
    29 #else
    30 # define VBVOAssertPtr(a) do {} while(0)
    3125#endif
    3226
  • trunk/src/VBox/Additions/common/VBoxVideo/VBVABase.cpp

    r64425 r64650  
    2121#include <VBox/err.h>
    2222// #include <VBox/log.h>
    23 #ifndef LINUX_VERSION_CODE
    24 # include <iprt/assert.h>
    25 # define VBVOAssert Assert
    26 #else
    27 # define VBVOAssert(a) do {} while(0)
    28 #endif
    2923#include <iprt/string.h>
    3024
  • trunk/src/VBox/GuestHost/HGSMI/HGSMICommon.cpp

    r64164 r64650  
    4242#define HGSMI_STRICT_ASSERT(expr) do {} while (0)
    4343#endif /* !HGSMI_STRICT */
     44
     45/*
     46 * We do not want assertions in Linux kernel code to reduce symbol dependencies.
     47 */
     48#if defined(IN_RING0) && defined(RT_OS_LINUX)
     49# define HGSMI_ASSERT_PTR_RETURN(a, b) if (!(a)) return (b)
     50#else
     51# define HGSMI_ASSERT_PTR_RETURN(a, b) if (!(a)) return (b)
     52#endif /* !IN_RING0 && RT_OS_LINUX */
    4453
    4554/* One-at-a-Time Hash from
     
    189198                   const HGSMIENV *pEnv)
    190199{
    191     AssertPtrReturn(pHeap, VERR_INVALID_PARAMETER);
    192     AssertPtrReturn(pvBase, VERR_INVALID_PARAMETER);
     200    HGSMI_ASSERT_PTR_RETURN(pHeap, VERR_INVALID_PARAMETER);
     201    HGSMI_ASSERT_PTR_RETURN(pvBase, VERR_INVALID_PARAMETER);
    193202
    194203    int rc = HGSMIAreaInitialize(&pHeap->area, pvBase, cbArea, offBase);
     
    368377    // LogFlowFunc(("pArea %p, offBuffer 0x%x\n", pArea, offBuffer));
    369378
    370     AssertPtrReturn(pArea, VERR_INVALID_PARAMETER);
    371     AssertPtrReturn(pChannelInfo, VERR_INVALID_PARAMETER);
     379    HGSMI_ASSERT_PTR_RETURN(pArea, VERR_INVALID_PARAMETER);
     380    HGSMI_ASSERT_PTR_RETURN(pChannelInfo, VERR_INVALID_PARAMETER);
    372381
    373382    /* Guest has prepared a command description at 'offBuffer'. */
  • trunk/src/VBox/GuestHost/HGSMI/HGSMIMemAlloc.cpp

    r62492 r64650  
    5959#include <iprt/string.h>
    6060
     61/*
     62 * We do not want assertions in Linux kernel code to reduce symbol dependencies.
     63 */
     64#if defined(IN_RING0) && defined(RT_OS_LINUX)
     65# define HGSMI_ASSERT_RETURN(a, b) if (!(a)) return (b)
     66# define HGSMI_ASSERT_FAILED() do {} while (0)
     67# define HGSMI_ASSERT(expr) do {} while (0)
     68#else
     69# define HGSMI_ASSERT_RETURN(a, b) AssertReturn(a, b)
     70# define HGSMI_ASSERT_FAILED() AssertFailed()
     71# define HGSMI_ASSERT(expr) Assert(expr)
     72#endif /* !IN_RING0 && RT_OS_LINUX */
    6173
    6274DECLINLINE(HGSMIOFFSET) hgsmiMADescriptor(HGSMIOFFSET off, bool fFree, HGSMIOFFSET order)
     
    222234    if (pBlock)
    223235    {
    224         AssertReturn(HGSMI_MA_DESC_IS_FREE(pBlock->descriptor), NULL);
     236        HGSMI_ASSERT_RETURN(HGSMI_MA_DESC_IS_FREE(pBlock->descriptor), NULL);
    225237
    226238        /* Where the block starts. */
     
    298310                {
    299311                    /* Should never happen because the new set of blocks is supposed to be smaller. */
    300                     AssertFailed();
     312                    HGSMI_ASSERT_FAILED();
    301313                    rc = VERR_OUT_OF_RESOURCES;
    302314                    break;
     
    325337    }
    326338
    327     Assert(cbRemaining == 0);
     339    HGSMI_ASSERT(cbRemaining == 0);
    328340
    329341    if (RT_SUCCESS(rc))
     
    354366                                  HGSMIMABLOCK **ppStart, HGSMIMABLOCK **ppEnd, HGSMISIZE *pcbBlocks)
    355367{
    356     Assert(HGSMI_MA_DESC_IS_FREE(pBlock->descriptor));
     368    HGSMI_ASSERT(HGSMI_MA_DESC_IS_FREE(pBlock->descriptor));
    357369
    358370    *pcbBlocks = HGSMIMAOrder2Size(HGSMI_MA_DESC_ORDER(pBlock->descriptor));
     
    418430        RTListForEach(&pMA->aListFreeBlocks[i], pIter, HGSMIMABLOCK, nodeFree)
    419431        {
    420             Assert(HGSMI_MA_DESC_ORDER(pIter->descriptor) == i);
     432            HGSMI_ASSERT(HGSMI_MA_DESC_ORDER(pIter->descriptor) == i);
    421433
    422434            HGSMISIZE cbBlocks;
     
    425437            hgsmiMAQueryFreeRange(pMA, pIter, cbRequired, &pFreeStart, &pFreeEnd, &cbBlocks);
    426438
    427             Assert((cbBlocks / HGSMI_MA_BLOCK_SIZE_MIN) * HGSMI_MA_BLOCK_SIZE_MIN == cbBlocks);
     439            HGSMI_ASSERT((cbBlocks / HGSMI_MA_BLOCK_SIZE_MIN) * HGSMI_MA_BLOCK_SIZE_MIN == cbBlocks);
    428440
    429441            /* Verify whether cbBlocks is enough for the requested block. */
     
    460472    HGSMIOFFSET order = HGSMIPopCnt32(cb - 1) - HGSMI_MA_DESC_ORDER_BASE;
    461473
    462     AssertReturn(HGSMIMAOrder2Size(order) >= cb, HGSMIOFFSET_VOID);
    463     AssertReturn(order < RT_ELEMENTS(pMA->aListFreeBlocks), HGSMIOFFSET_VOID);
     474    HGSMI_ASSERT_RETURN(HGSMIMAOrder2Size(order) >= cb, HGSMIOFFSET_VOID);
     475    HGSMI_ASSERT_RETURN(order < RT_ELEMENTS(pMA->aListFreeBlocks), HGSMIOFFSET_VOID);
    464476
    465477    HGSMIMABLOCK *pBlock = hgsmiMAGetFreeBlock(pMA, order);
     
    489501
    490502    /* Find the block corresponding to the offset. */
    491     Assert((off / HGSMI_MA_BLOCK_SIZE_MIN) * HGSMI_MA_BLOCK_SIZE_MIN == off);
     503    HGSMI_ASSERT((off / HGSMI_MA_BLOCK_SIZE_MIN) * HGSMI_MA_BLOCK_SIZE_MIN == off);
    492504
    493505    HGSMIMABLOCK *pBlock = HGSMIMASearchOffset(pMA, off);
     
    503515    }
    504516
    505     AssertFailed();
     517    HGSMI_ASSERT_FAILED();
    506518}
    507519
     
    510522                const HGSMIENV *pEnv)
    511523{
    512     AssertReturn(pArea->cbArea < UINT32_C(0x80000000), VERR_INVALID_PARAMETER);
    513     AssertReturn(pArea->cbArea >= HGSMI_MA_BLOCK_SIZE_MIN, VERR_INVALID_PARAMETER);
     524    HGSMI_ASSERT_RETURN(pArea->cbArea < UINT32_C(0x80000000), VERR_INVALID_PARAMETER);
     525    HGSMI_ASSERT_RETURN(pArea->cbArea >= HGSMI_MA_BLOCK_SIZE_MIN, VERR_INVALID_PARAMETER);
    514526
    515527    RT_ZERO(*pMA);
     
    568580    }
    569581
    570     AssertFailed();
     582    HGSMI_ASSERT_FAILED();
    571583    return HGSMIOFFSET_VOID;
    572584}
     
    579591    }
    580592
    581     AssertFailed();
     593    HGSMI_ASSERT_FAILED();
    582594    return NULL;
    583595}
     
    598610    else
    599611    {
    600         AssertFailed();
     612        HGSMI_ASSERT_FAILED();
    601613    }
    602614}
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