VirtualBox

Changeset 90807 in vbox for trunk


Ignore:
Timestamp:
Aug 23, 2021 7:31:36 PM (3 years ago)
Author:
vboxsync
Message:

Storage: More VALID_PTR -> RT_VALID_PTR/AssertPtr.

File:
1 edited

Legend:

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

    r90806 r90807  
    72287228                 pDiskFrom, nImage, pDiskTo, pszBackend, pszFilename, fMoveByRename, cbSize, nImageFromSame, nImageToSame, uImageFlags, pDstUuid, uOpenFlags, pVDIfsOperation, pDstVDIfsImage, pDstVDIfsOperation));
    72297229
     7230    /* Check arguments. */
     7231    AssertReturn(pDiskFrom, VERR_INVALID_POINTER);
     7232    AssertMsg(pDiskFrom->u32Signature == VDISK_SIGNATURE,
     7233              ("u32Signature=%08x\n", pDiskFrom->u32Signature));
     7234
    72307235    PVDINTERFACEPROGRESS pIfProgress    = VDIfProgressGet(pVDIfsOperation);
    72317236    PVDINTERFACEPROGRESS pDstIfProgress = VDIfProgressGet(pDstVDIfsOperation);
    72327237
    72337238    do {
    7234         /* Check arguments. */
    7235         AssertMsgBreakStmt(VALID_PTR(pDiskFrom), ("pDiskFrom=%#p\n", pDiskFrom),
    7236                            rc = VERR_INVALID_PARAMETER);
    7237         AssertMsg(pDiskFrom->u32Signature == VDISK_SIGNATURE,
    7238                   ("u32Signature=%08x\n", pDiskFrom->u32Signature));
    7239 
    72407239        rc2 = vdThreadStartRead(pDiskFrom);
    72417240        AssertRC(rc2);
     
    72437242        PVDIMAGE pImageFrom = vdGetImageByNumber(pDiskFrom, nImage);
    72447243        AssertPtrBreakStmt(pImageFrom, rc = VERR_VD_IMAGE_NOT_FOUND);
    7245         AssertMsgBreakStmt(VALID_PTR(pDiskTo), ("pDiskTo=%#p\n", pDiskTo),
    7246                            rc = VERR_INVALID_PARAMETER);
     7244        AssertPtrBreakStmt(pDiskTo, rc = VERR_INVALID_POINTER);
    72477245        AssertMsg(pDiskTo->u32Signature == VDISK_SIGNATURE,
    72487246                  ("u32Signature=%08x\n", pDiskTo->u32Signature));
     
    72827280
    72837281        /* pszFilename is allowed to be NULL, as this indicates copy to the existing image. */
    7284         AssertMsgBreakStmt(pszFilename == NULL || (VALID_PTR(pszFilename) && *pszFilename),
    7285                            ("pszFilename=%#p \"%s\"\n", pszFilename, pszFilename),
    7286                            rc = VERR_INVALID_PARAMETER);
     7282        if (pszFilename)
     7283        {
     7284            AssertPtrBreakStmt(pszFilename, rc = VERR_INVALID_POINTER);
     7285            AssertBreakStmt(*pszFilename != '\0', rc = VERR_INVALID_PARAMETER);
     7286        }
    72877287
    72887288        uint64_t cbSizeFrom;
     
    75387538    LogFlowFunc(("pDisk=%#p nImage=%u pVDIfsOperation=%#p\n",
    75397539                 pDisk, nImage, pVDIfsOperation));
     7540    /* Check arguments. */
     7541    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     7542    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
     7543              ("u32Signature=%08x\n", pDisk->u32Signature));
    75407544
    75417545    PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);
    75427546
    75437547    do {
    7544         /* Check arguments. */
    7545         AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),
    7546                            rc = VERR_INVALID_PARAMETER);
    7547         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
    7548                   ("u32Signature=%08x\n", pDisk->u32Signature));
    7549 
    75507548        rc2 = vdThreadStartRead(pDisk);
    75517549        AssertRC(rc2);
     
    76357633    LogFlowFunc(("pDisk=%#p cbSize=%llu pVDIfsOperation=%#p\n",
    76367634                 pDisk, cbSize, pVDIfsOperation));
     7635    /* Check arguments. */
     7636    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     7637    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
     7638              ("u32Signature=%08x\n", pDisk->u32Signature));
    76377639
    76387640    PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);
    76397641
    76407642    do {
    7641         /* Check arguments. */
    7642         AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),
    7643                            rc = VERR_INVALID_PARAMETER);
    7644         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
    7645                   ("u32Signature=%08x\n", pDisk->u32Signature));
    7646 
    76477643        rc2 = vdThreadStartRead(pDisk);
    76487644        AssertRC(rc2);
     
    77527748
    77537749    LogFlowFunc(("pDisk=%#p pVDIfsOperation=%#p\n", pDisk, pVDIfsOperation));
     7750    /* Check arguments. */
     7751    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     7752    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
     7753              ("u32Signature=%08x\n", pDisk->u32Signature));
    77547754
    77557755    PVDINTERFACEPROGRESS pIfProgress = VDIfProgressGet(pVDIfsOperation);
    77567756
    77577757    do {
    7758         /* Check arguments. */
    7759         AssertMsgBreakStmt(VALID_PTR(pDisk), ("pDisk=%#p\n", pDisk),
    7760                            rc = VERR_INVALID_PARAMETER);
    7761         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE,
    7762                   ("u32Signature=%08x\n", pDisk->u32Signature));
    7763 
    77647758        rc2 = vdThreadStartRead(pDisk);
    77657759        AssertRC(rc2);
     
    81368130{
    81378131    int rc = VINF_SUCCESS;
     8132
     8133    LogFlowFunc(("pDisk=%#p\n", pDisk));
     8134    /* sanity check */
     8135    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     8136    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8137
     8138    /* Lock the entire operation. */
     8139    int rc2 = vdThreadStartWrite(pDisk);
     8140    AssertRC(rc2);
     8141    bool fLockWrite = true;
     8142
     8143    PVDCACHE pCache = pDisk->pCache;
     8144    if (pCache)
     8145    {
     8146        rc2 = pCache->Backend->pfnClose(pCache->pBackendData, false);
     8147        if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
     8148            rc = rc2;
     8149
     8150        if (pCache->pszFilename)
     8151            RTStrFree(pCache->pszFilename);
     8152        RTMemFree(pCache);
     8153    }
     8154
     8155    PVDIMAGE pImage = pDisk->pLast;
     8156    while (RT_VALID_PTR(pImage))
     8157    {
     8158        PVDIMAGE pPrev = pImage->pPrev;
     8159        /* Remove image from list of opened images. */
     8160        vdRemoveImageFromList(pDisk, pImage);
     8161        /* Close image. */
     8162        rc2 = pImage->Backend->pfnClose(pImage->pBackendData, false);
     8163        if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
     8164            rc = rc2;
     8165        /* Free remaining resources related to the image. */
     8166        RTStrFree(pImage->pszFilename);
     8167        RTMemFree(pImage);
     8168        pImage = pPrev;
     8169    }
     8170    Assert(!RT_VALID_PTR(pDisk->pLast));
     8171
     8172    if (RT_UNLIKELY(fLockWrite))
     8173    {
     8174        rc2 = vdThreadFinishWrite(pDisk);
     8175        AssertRC(rc2);
     8176    }
     8177
     8178    LogFlowFunc(("returns %Rrc\n", rc));
     8179    return rc;
     8180}
     8181
     8182
     8183VBOXDDU_DECL(int) VDFilterRemoveAll(PVDISK pDisk)
     8184{
     8185    int rc = VINF_SUCCESS;
    81388186    int rc2;
    81398187    bool fLockWrite = false;
     
    81518199        fLockWrite = true;
    81528200
    8153         PVDCACHE pCache = pDisk->pCache;
    8154         if (pCache)
    8155         {
    8156             rc2 = pCache->Backend->pfnClose(pCache->pBackendData, false);
    8157             if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
    8158                 rc = rc2;
    8159 
    8160             if (pCache->pszFilename)
    8161                 RTStrFree(pCache->pszFilename);
    8162             RTMemFree(pCache);
    8163         }
    8164 
    8165         PVDIMAGE pImage = pDisk->pLast;
    8166         while (VALID_PTR(pImage))
    8167         {
    8168             PVDIMAGE pPrev = pImage->pPrev;
    8169             /* Remove image from list of opened images. */
    8170             vdRemoveImageFromList(pDisk, pImage);
    8171             /* Close image. */
    8172             rc2 = pImage->Backend->pfnClose(pImage->pBackendData, false);
    8173             if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
    8174                 rc = rc2;
    8175             /* Free remaining resources related to the image. */
    8176             RTStrFree(pImage->pszFilename);
    8177             RTMemFree(pImage);
    8178             pImage = pPrev;
    8179         }
    8180         Assert(!VALID_PTR(pDisk->pLast));
    8181     } while (0);
    8182 
    8183     if (RT_UNLIKELY(fLockWrite))
    8184     {
    8185         rc2 = vdThreadFinishWrite(pDisk);
    8186         AssertRC(rc2);
    8187     }
    8188 
    8189     LogFlowFunc(("returns %Rrc\n", rc));
    8190     return rc;
    8191 }
    8192 
    8193 
    8194 VBOXDDU_DECL(int) VDFilterRemoveAll(PVDISK pDisk)
    8195 {
    8196     int rc = VINF_SUCCESS;
    8197     int rc2;
    8198     bool fLockWrite = false;
    8199 
    8200     LogFlowFunc(("pDisk=%#p\n", pDisk));
    8201     do
    8202     {
    8203         /* sanity check */
    8204         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    8205         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    8206 
    8207         /* Lock the entire operation. */
    8208         rc2 = vdThreadStartWrite(pDisk);
    8209         AssertRC(rc2);
    8210         fLockWrite = true;
    8211 
    82128201        PVDFILTER pFilter, pFilterNext;
    82138202        RTListForEachSafe(&pDisk->ListFilterChainWrite, pFilter, pFilterNext, VDFILTER, ListNodeChainWrite)
     
    82468235    LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbRead=%zu\n",
    82478236                 pDisk, uOffset, pvBuf, cbRead));
     8237    /* sanity check */
     8238    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     8239    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8240
     8241    /* Check arguments. */
     8242    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     8243    AssertReturn(cbRead > 0, VERR_INVALID_PARAMETER);
     8244
    82488245    do
    82498246    {
    8250         /* sanity check */
    8251         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    8252         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    8253 
    8254         /* Check arguments. */
    8255         AssertMsgBreakStmt(VALID_PTR(pvBuf),
    8256                            ("pvBuf=%#p\n", pvBuf),
    8257                            rc = VERR_INVALID_PARAMETER);
    8258         AssertMsgBreakStmt(cbRead,
    8259                            ("cbRead=%zu\n", cbRead),
    8260                            rc = VERR_INVALID_PARAMETER);
    8261 
    82628247        rc2 = vdThreadStartRead(pDisk);
    82638248        AssertRC(rc2);
     
    83118296    LogFlowFunc(("pDisk=%#p uOffset=%llu pvBuf=%p cbWrite=%zu\n",
    83128297                 pDisk, uOffset, pvBuf, cbWrite));
     8298    /* sanity check */
     8299    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     8300    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8301
     8302    /* Check arguments. */
     8303    AssertPtrReturn(pvBuf, VERR_INVALID_POINTER);
     8304    AssertReturn(cbWrite > 0, VERR_INVALID_PARAMETER);
     8305
    83138306    do
    83148307    {
    8315         /* sanity check */
    8316         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    8317         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    8318 
    8319         /* Check arguments. */
    8320         AssertMsgBreakStmt(VALID_PTR(pvBuf),
    8321                            ("pvBuf=%#p\n", pvBuf),
    8322                            rc = VERR_INVALID_PARAMETER);
    8323         AssertMsgBreakStmt(cbWrite,
    8324                            ("cbWrite=%zu\n", cbWrite),
    8325                            rc = VERR_INVALID_PARAMETER);
    8326 
    83278308        rc2 = vdThreadStartWrite(pDisk);
    83288309        AssertRC(rc2);
     
    86058586    LogFlowFunc(("pDisk=%#p nImage=%u pPCHSGeometry=%#p\n",
    86068587                 pDisk, nImage, pPCHSGeometry));
     8588    /* sanity check */
     8589    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     8590    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8591
     8592    /* Check arguments. */
     8593    AssertPtrReturn(pPCHSGeometry, VERR_INVALID_POINTER);
     8594
    86078595    do
    86088596    {
    8609         /* sanity check */
    8610         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    8611         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    8612 
    8613         /* Check arguments. */
    8614         AssertMsgBreakStmt(VALID_PTR(pPCHSGeometry),
    8615                            ("pPCHSGeometry=%#p\n", pPCHSGeometry),
    8616                            rc = VERR_INVALID_PARAMETER);
    8617 
    86188597        rc2 = vdThreadStartRead(pDisk);
    86198598        AssertRC(rc2);
     
    86598638                 pDisk, nImage, pPCHSGeometry, pPCHSGeometry->cCylinders,
    86608639                 pPCHSGeometry->cHeads, pPCHSGeometry->cSectors));
     8640    /* sanity check */
     8641    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     8642    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     8643
     8644    /* Check arguments. */
     8645    AssertPtrReturn(pPCHSGeometry, VERR_INVALID_POINTER);
     8646    AssertMsgReturn(   pPCHSGeometry->cHeads <= 16
     8647                    && pPCHSGeometry->cSectors <= 63,
     8648                    ("PCHS=%u/%u/%u\n", pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads, pPCHSGeometry->cSectors),
     8649                    VERR_INVALID_PARAMETER);
    86618650    do
    86628651    {
    8663         /* sanity check */
    8664         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    8665         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    8666 
    8667         /* Check arguments. */
    8668         AssertMsgBreakStmt(   VALID_PTR(pPCHSGeometry)
    8669                            && pPCHSGeometry->cHeads <= 16
    8670                            && pPCHSGeometry->cSectors <= 63,
    8671                            ("pPCHSGeometry=%#p PCHS=%u/%u/%u\n", pPCHSGeometry,
    8672                             pPCHSGeometry->cCylinders, pPCHSGeometry->cHeads,
    8673                             pPCHSGeometry->cSectors),
    8674                            rc = VERR_INVALID_PARAMETER);
    8675 
    86768652        rc2 = vdThreadStartWrite(pDisk);
    86778653        AssertRC(rc2);
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