VirtualBox

Changeset 73097 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Jul 12, 2018 9:06:33 PM (6 years ago)
Author:
vboxsync
Message:

*: Made RT_UOFFSETOF, RT_OFFSETOF, RT_UOFFSETOF_ADD and RT_OFFSETOF_ADD work like builtin_offsetof() and require compile time resolvable requests, adding RT_UOFFSETOF_DYN for the dynamic questions that can only be answered at runtime.

Location:
trunk/src/VBox/Storage
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/CUE.cpp

    r72455 r73097  
    276276    {
    277277        PVDREGIONLIST pRegionListNew = (PVDREGIONLIST)RTMemRealloc(pThis->pRegionList,
    278                                                                    RT_UOFFSETOF(VDREGIONLIST, aRegions[cTracksMax]));
     278                                                                   RT_UOFFSETOF_DYN(VDREGIONLIST, aRegions[cTracksMax]));
    279279        if (pRegionListNew)
    280280        {
  • trunk/src/VBox/Storage/ISCSI.cpp

    r69500 r73097  
    27722772     */
    27732773    size_t cI2TSegs = 2*(pScsiReq->cI2TSegs + 1);
    2774     pIScsiPDU = (PISCSIPDUTX)RTMemAllocZ(RT_OFFSETOF(ISCSIPDUTX, aISCSIReq[cI2TSegs]));
     2774    pIScsiPDU = (PISCSIPDUTX)RTMemAllocZ(RT_UOFFSETOF_DYN(ISCSIPDUTX, aISCSIReq[cI2TSegs]));
    27752775    if (!pIScsiPDU)
    27762776        return VERR_NO_MEMORY;
     
    48364836    Assert(cbSegs == cbToRead);
    48374837
    4838     PSCSIREQ pReq = (PSCSIREQ)RTMemAllocZ(RT_OFFSETOF(SCSIREQ, aSegs[cT2ISegs]));
     4838    PSCSIREQ pReq = (PSCSIREQ)RTMemAllocZ(RT_UOFFSETOF_DYN(SCSIREQ, aSegs[cT2ISegs]));
    48394839    if (RT_LIKELY(pReq))
    48404840    {
     
    49634963    Assert(cbSegs == cbToWrite);
    49644964
    4965     PSCSIREQ pReq = (PSCSIREQ)RTMemAllocZ(RT_OFFSETOF(SCSIREQ, aSegs[cI2TSegs]));
     4965    PSCSIREQ pReq = (PSCSIREQ)RTMemAllocZ(RT_UOFFSETOF_DYN(SCSIREQ, aSegs[cI2TSegs]));
    49664966    if (RT_LIKELY(pReq))
    49674967    {
  • trunk/src/VBox/Storage/VD.cpp

    r72054 r73097  
    544544{
    545545    int rc = VINF_SUCCESS;
    546     PVDREGIONLIST pRegionListNew = (PVDREGIONLIST)RTMemDup(pRegionList, RT_UOFFSETOF(VDREGIONLIST, aRegions[pRegionList->cRegions]));
     546    PVDREGIONLIST pRegionListNew = (PVDREGIONLIST)RTMemDup(pRegionList,
     547                                                           RT_UOFFSETOF_DYN(VDREGIONLIST, aRegions[pRegionList->cRegions]));
    547548    if (RT_LIKELY(pRegionListNew))
    548549    {
     
    11861187DECLINLINE(PVDMETAXFER) vdMetaXferAlloc(PVDIOSTORAGE pIoStorage, uint64_t uOffset, size_t cb)
    11871188{
    1188     PVDMETAXFER pMetaXfer = (PVDMETAXFER)RTMemAlloc(RT_OFFSETOF(VDMETAXFER, abData[cb]));
     1189    PVDMETAXFER pMetaXfer = (PVDMETAXFER)RTMemAlloc(RT_UOFFSETOF_DYN(VDMETAXFER, abData[cb]));
    11891190
    11901191    if (RT_LIKELY(pMetaXfer))
  • trunk/src/VBox/Storage/VDIfVfs.cpp

    r69977 r73097  
    357357    { /* ObjSet */
    358358        RTVFSOBJSETOPS_VERSION,
    359         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     359        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    360360        vdIfVfsFile_SetMode,
    361361        vdIfVfsFile_SetTimes,
  • trunk/src/VBox/Storage/VDVfs.cpp

    r73061 r73097  
    548548    { /* ObjSet */
    549549        RTVFSOBJSETOPS_VERSION,
    550         RT_OFFSETOF(RTVFSFILEOPS, Stream.Obj) - RT_OFFSETOF(RTVFSFILEOPS, ObjSet),
     550        RT_UOFFSETOF(RTVFSFILEOPS, ObjSet) - RT_UOFFSETOF(RTVFSFILEOPS, Stream.Obj),
    551551        vdVfsFile_SetMode,
    552552        vdVfsFile_SetTimes,
  • trunk/src/VBox/Storage/VHD.cpp

    r72577 r73097  
    16741674            }
    16751675
    1676             PVHDIMAGEEXPAND pExpand = (PVHDIMAGEEXPAND)RTMemAllocZ(RT_OFFSETOF(VHDIMAGEEXPAND, au8Bitmap[pImage->cDataBlockBitmapSectors * VHD_SECTOR_SIZE]));
     1676            PVHDIMAGEEXPAND pExpand;
     1677            pExpand = (PVHDIMAGEEXPAND)RTMemAllocZ(RT_UOFFSETOF_DYN(VHDIMAGEEXPAND,
     1678                                                                    au8Bitmap[pImage->cDataBlockBitmapSectors * VHD_SECTOR_SIZE]));
    16771679            bool fIoInProgress = false;
    16781680
  • trunk/src/VBox/Storage/VMDK.cpp

    r70853 r73097  
    666666        cbBuf--;
    667667        cbInjected = 1;
    668         pInflateState->iOffset = RT_OFFSETOF(VMDKMARKER, uType);
     668        pInflateState->iOffset = RT_UOFFSETOF(VMDKMARKER, uType);
    669669    }
    670670    if (!cbBuf)
     
    704704    {
    705705        rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage,
    706                                    uOffset, pMarker, RT_OFFSETOF(VMDKMARKER, uType));
     706                                   uOffset, pMarker, RT_UOFFSETOF(VMDKMARKER, uType));
    707707        if (RT_FAILURE(rc))
    708708            return rc;
     
    710710    else
    711711    {
    712         memcpy(pMarker, pcvMarker, RT_OFFSETOF(VMDKMARKER, uType));
     712        memcpy(pMarker, pcvMarker, RT_UOFFSETOF(VMDKMARKER, uType));
    713713        /* pcvMarker endianness has already been partially transformed, fix it */
    714714        pMarker->uSector = RT_H2LE_U64(pMarker->uSector);
     
    730730    /* Compressed grain marker. Data follows immediately. */
    731731    rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage,
    732                                uOffset + RT_OFFSETOF(VMDKMARKER, uType),
     732                               uOffset + RT_UOFFSETOF(VMDKMARKER, uType),
    733733                                (uint8_t *)pExtent->pvCompGrain
    734                               + RT_OFFSETOF(VMDKMARKER, uType),
     734                              + RT_UOFFSETOF(VMDKMARKER, uType),
    735735                               RT_ALIGN_Z(  cbCompSize
    736                                           + RT_OFFSETOF(VMDKMARKER, uType),
     736                                          + RT_UOFFSETOF(VMDKMARKER, uType),
    737737                                          512)
    738                                - RT_OFFSETOF(VMDKMARKER, uType));
     738                               - RT_UOFFSETOF(VMDKMARKER, uType));
    739739
    740740    if (puLBA)
     
    742742    if (pcbMarkerData)
    743743        *pcbMarkerData = RT_ALIGN(  cbCompSize
    744                                   + RT_OFFSETOF(VMDKMARKER, uType),
     744                                  + RT_UOFFSETOF(VMDKMARKER, uType),
    745745                                  512);
    746746
    747747#ifdef VMDK_USE_BLOCK_DECOMP_API
    748748    rc = RTZipBlockDecompress(RTZIPTYPE_ZLIB, 0 /*fFlags*/,
    749                               pExtent->pvCompGrain, cbCompSize + RT_OFFSETOF(VMDKMARKER, uType), NULL,
     749                              pExtent->pvCompGrain, cbCompSize + RT_UOFFSETOF(VMDKMARKER, uType), NULL,
    750750                              pvBuf, cbToRead, &cbActuallyRead);
    751751#else
     
    753753    InflateState.pImage = pImage;
    754754    InflateState.iOffset = -1;
    755     InflateState.cbCompGrain = cbCompSize + RT_OFFSETOF(VMDKMARKER, uType);
     755    InflateState.cbCompGrain = cbCompSize + RT_UOFFSETOF(VMDKMARKER, uType);
    756756    InflateState.pvCompGrain = pExtent->pvCompGrain;
    757757
     
    782782        pvBuf = (const uint8_t *)pvBuf + 1;
    783783        cbBuf--;
    784         pDeflateState->iOffset = RT_OFFSETOF(VMDKMARKER, uType);
     784        pDeflateState->iOffset = RT_UOFFSETOF(VMDKMARKER, uType);
    785785    }
    786786    if (!cbBuf)
     
    842842        pMarker->uSector = RT_H2LE_U64(uLBA);
    843843        pMarker->cbSize = RT_H2LE_U32(  DeflateState.iOffset
    844                                       - RT_OFFSETOF(VMDKMARKER, uType));
     844                                      - RT_UOFFSETOF(VMDKMARKER, uType));
    845845        rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pExtent->pFile->pStorage,
    846846                                    uOffset, pMarker, uSize);
     
    26062606        Header.magicNumber = RT_H2LE_U32(VMDK_SPARSE_MAGICNUMBER);
    26072607        rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage,
    2608                                    RT_OFFSETOF(SparseExtentHeader, version),
     2608                                   RT_UOFFSETOF(SparseExtentHeader, version),
    26092609                                   &Header.version,
    26102610                                     sizeof(Header)
    2611                                    - RT_OFFSETOF(SparseExtentHeader, version));
     2611                                   - RT_UOFFSETOF(SparseExtentHeader, version));
    26122612    }
    26132613
     
    30393039                         */
    30403040                        uint64_t u64DescSizeNew = RT_H2LE_U64(pExtent->cDescriptorSectors);
    3041                         rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pFile->pStorage, RT_OFFSETOF(SparseExtentHeader, descriptorSize),
     3041                        rc = vdIfIoIntFileWriteSync(pImage->pIfIo, pFile->pStorage,
     3042                                                    RT_UOFFSETOF(SparseExtentHeader, descriptorSize),
    30423043                                                    &u64DescSizeNew, sizeof(u64DescSizeNew));
    30433044                        if (RT_FAILURE(rc))
     
    50395040            rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage,
    50405041                                       VMDK_SECTOR2BYTE(uGrainSectorAbs),
    5041                                        &Marker, RT_OFFSETOF(VMDKMARKER, uType));
     5042                                       &Marker, RT_UOFFSETOF(VMDKMARKER, uType));
    50425043            if (RT_FAILURE(rc))
    50435044                return rc;
     
    50505051                rc = vdIfIoIntFileReadSync(pImage->pIfIo, pExtent->pFile->pStorage,
    50515052                                             VMDK_SECTOR2BYTE(uGrainSectorAbs)
    5052                                            + RT_OFFSETOF(VMDKMARKER, uType),
     5053                                           + RT_UOFFSETOF(VMDKMARKER, uType),
    50535054                                           &Marker.uType, sizeof(Marker.uType));
    50545055                if (RT_FAILURE(rc))
     
    50975098                if (uSector > Marker.uSector + pExtent->cSectorsPerGrain)
    50985099                {
    5099                     uGrainSectorAbs += VMDK_BYTE2SECTOR(RT_ALIGN(Marker.cbSize + RT_OFFSETOF(VMDKMARKER, uType), 512));
     5100                    uGrainSectorAbs += VMDK_BYTE2SECTOR(RT_ALIGN(Marker.cbSize + RT_UOFFSETOF(VMDKMARKER, uType), 512));
    51005101                    continue;
    51015102                }
  • trunk/src/VBox/Storage/testcase/VDIoBackendMem.cpp

    r69500 r73097  
    156156        RTSgBufSegArrayCreate(pSgBuf, NULL, &cSegs, cbTransfer);
    157157
    158     pReq = (PVDIOBACKENDREQ)RTMemAlloc(RT_OFFSETOF(VDIOBACKENDREQ, aSegs[cSegs]));
     158    pReq = (PVDIOBACKENDREQ)RTMemAlloc(RT_UOFFSETOF_DYN(VDIOBACKENDREQ, aSegs[cSegs]));
    159159    if (!pReq)
    160160        return VERR_NO_MEMORY;
  • trunk/src/VBox/Storage/testcase/VDScript.cpp

    r69500 r73097  
    29502950        }
    29512951
    2952         pFn = (PVDSCRIPTFN)RTMemAllocZ(RT_OFFSETOF(VDSCRIPTFN, aenmArgTypes[paCallbacks->cArgs]));
     2952        pFn = (PVDSCRIPTFN)RTMemAllocZ(RT_UOFFSETOF_DYN(VDSCRIPTFN, aenmArgTypes[paCallbacks->cArgs]));
    29532953        if (!pFn)
    29542954        {
  • trunk/src/VBox/Storage/testcase/VDScriptAst.cpp

    r69500 r73097  
    349349DECLHIDDEN(PVDSCRIPTASTIDE) vdScriptAstNodeIdeAlloc(size_t cchIde)
    350350{
    351     PVDSCRIPTASTIDE pAstNode = (PVDSCRIPTASTIDE)RTMemAllocZ(RT_OFFSETOF(VDSCRIPTASTIDE, aszIde[cchIde + 1]));
     351    PVDSCRIPTASTIDE pAstNode = (PVDSCRIPTASTIDE)RTMemAllocZ(RT_UOFFSETOF_DYN(VDSCRIPTASTIDE, aszIde[cchIde + 1]));
    352352    if (pAstNode)
    353353    {
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