VirtualBox

Changeset 90812 in vbox


Ignore:
Timestamp:
Aug 23, 2021 8:08:03 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

    r90811 r90812  
    93399339                                  PRTUUID pUuid)
    93409340{
    9341     int rc = VINF_SUCCESS;
    9342     int rc2;
    9343     bool fLockRead = false;
    9344 
    93459341    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid));
    9346     do
    9347     {
    9348         /* sanity check */
    9349         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9350         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9351 
    9352         /* Check arguments. */
    9353         AssertMsgBreakStmt(VALID_PTR(pUuid),
    9354                            ("pUuid=%#p\n", pUuid),
    9355                            rc = VERR_INVALID_PARAMETER);
    9356 
    9357         rc2 = vdThreadStartRead(pDisk);
    9358         AssertRC(rc2);
    9359         fLockRead = true;
    9360 
    9361         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9362         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9363 
     9342    /* sanity check */
     9343    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9344    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9345
     9346    /* Check arguments. */
     9347    AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9348
     9349    /* Do the job. */
     9350    int rc2 = vdThreadStartRead(pDisk);
     9351    AssertRC(rc2);
     9352
     9353    int rc;
     9354    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9355    AssertPtr(pImage);
     9356    if (pImage)
    93649357        rc = pImage->Backend->pfnGetParentUuid(pImage->pBackendData, pUuid);
    9365     } while (0);
    9366 
    9367     if (RT_UNLIKELY(fLockRead))
    9368     {
    9369         rc2 = vdThreadFinishRead(pDisk);
    9370         AssertRC(rc2);
    9371     }
     9358    else
     9359        rc = VERR_VD_IMAGE_NOT_FOUND;
     9360
     9361    rc2 = vdThreadFinishRead(pDisk);
     9362    AssertRC(rc2);
    93729363
    93739364    LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid));
     
    93799370                                  PCRTUUID pUuid)
    93809371{
    9381     int rc;
    9382     int rc2;
    9383     bool fLockWrite = false;
    9384 
    93859372    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n",
    93869373                 pDisk, nImage, pUuid, pUuid));
    9387     do
    9388     {
    9389         /* sanity check */
    9390         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9391         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9392 
    9393         /* Check arguments. */
    9394         AssertMsgBreakStmt(VALID_PTR(pUuid) || pUuid == NULL,
    9395                            ("pUuid=%#p\n", pUuid),
    9396                            rc = VERR_INVALID_PARAMETER);
    9397 
    9398         rc2 = vdThreadStartWrite(pDisk);
    9399         AssertRC(rc2);
    9400         fLockWrite = true;
    9401 
    9402         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9403         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9404 
    9405         RTUUID Uuid;
    9406         if (!pUuid)
    9407         {
    9408             RTUuidCreate(&Uuid);
    9409             pUuid = &Uuid;
    9410         }
     9374    /* sanity check */
     9375    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9376    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9377
     9378    /* Check arguments. */
     9379    RTUUID Uuid;
     9380    if (pUuid)
     9381        AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9382    else
     9383    {
     9384        int rc = RTUuidCreate(&Uuid);
     9385        AssertRCReturn(rc, rc);
     9386        pUuid = &Uuid;
     9387    }
     9388
     9389    /* Do the job. */
     9390    int rc2 = vdThreadStartWrite(pDisk);
     9391    AssertRC(rc2);
     9392
     9393    int rc;
     9394    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9395    AssertPtr(pImage);
     9396    if (pImage)
    94119397        rc = pImage->Backend->pfnSetParentUuid(pImage->pBackendData, pUuid);
    9412     } while (0);
    9413 
    9414     if (RT_UNLIKELY(fLockWrite))
    9415     {
    9416         rc2 = vdThreadFinishWrite(pDisk);
    9417         AssertRC(rc2);
    9418     }
     9398    else
     9399        rc = VERR_VD_IMAGE_NOT_FOUND;
     9400
     9401    rc2 = vdThreadFinishWrite(pDisk);
     9402    AssertRC(rc2);
    94199403
    94209404    LogFlowFunc(("returns %Rrc\n", rc));
     
    94259409VBOXDDU_DECL(void) VDDumpImages(PVDISK pDisk)
    94269410{
    9427     int rc2;
    9428     bool fLockRead = false;
    9429 
    9430     do
    9431     {
    9432         /* sanity check */
    9433         AssertPtrBreak(pDisk);
    9434         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9435 
    9436         if (!pDisk->pInterfaceError || !VALID_PTR(pDisk->pInterfaceError->pfnMessage))
    9437             pDisk->pInterfaceError->pfnMessage = vdLogMessage;
    9438 
    9439         rc2 = vdThreadStartRead(pDisk);
    9440         AssertRC(rc2);
    9441         fLockRead = true;
    9442 
    9443         vdMessageWrapper(pDisk, "--- Dumping VD Disk, Images=%u\n", pDisk->cImages);
    9444         for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext)
    9445         {
    9446             vdMessageWrapper(pDisk, "Dumping VD image \"%s\" (Backend=%s)\n",
    9447                              pImage->pszFilename, pImage->Backend->pszBackendName);
    9448             pImage->Backend->pfnDump(pImage->pBackendData);
    9449         }
    9450     } while (0);
    9451 
    9452     if (RT_UNLIKELY(fLockRead))
    9453     {
    9454         rc2 = vdThreadFinishRead(pDisk);
    9455         AssertRC(rc2);
    9456     }
     9411    /* sanity check */
     9412    AssertPtrReturnVoid(pDisk);
     9413    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9414
     9415    if (!pDisk->pInterfaceError || !RT_VALID_PTR(pDisk->pInterfaceError->pfnMessage)) /** @todo r=bird: first test is boinkers. */
     9416        pDisk->pInterfaceError->pfnMessage = vdLogMessage;
     9417
     9418    int rc2 = vdThreadStartRead(pDisk);
     9419    AssertRC(rc2);
     9420
     9421    vdMessageWrapper(pDisk, "--- Dumping VD Disk, Images=%u\n", pDisk->cImages);
     9422    for (PVDIMAGE pImage = pDisk->pBase; pImage; pImage = pImage->pNext)
     9423    {
     9424        vdMessageWrapper(pDisk, "Dumping VD image \"%s\" (Backend=%s)\n",
     9425                         pImage->pszFilename, pImage->Backend->pszBackendName);
     9426        pImage->Backend->pfnDump(pImage->pBackendData);
     9427    }
     9428
     9429    rc2 = vdThreadFinishRead(pDisk);
     9430    AssertRC(rc2);
    94579431}
    94589432
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