VirtualBox

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


Ignore:
Timestamp:
Aug 23, 2021 8:02:56 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
146446
Message:

Storage: More VALID_PTR -> RT_VALID_PTR/AssertPtr.

File:
1 edited

Legend:

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

    r90810 r90811  
    91379137                               char *pszComment, unsigned cbComment)
    91389138{
    9139     int rc;
    9140     int rc2;
    9141     bool fLockRead = false;
    9142 
    91439139    LogFlowFunc(("pDisk=%#p nImage=%u pszComment=%#p cbComment=%u\n",
    91449140                 pDisk, nImage, pszComment, cbComment));
    9145     do
    9146     {
    9147         /* sanity check */
    9148         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9149         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9150 
    9151         /* Check arguments. */
    9152         AssertMsgBreakStmt(VALID_PTR(pszComment),
    9153                            ("pszComment=%#p \"%s\"\n", pszComment, pszComment),
    9154                            rc = VERR_INVALID_PARAMETER);
    9155         AssertMsgBreakStmt(cbComment,
    9156                            ("cbComment=%u\n", cbComment),
    9157                            rc = VERR_INVALID_PARAMETER);
    9158 
    9159         rc2 = vdThreadStartRead(pDisk);
    9160         AssertRC(rc2);
    9161         fLockRead = true;
    9162 
    9163         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9164         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9165 
    9166         rc = pImage->Backend->pfnGetComment(pImage->pBackendData, pszComment,
    9167                                             cbComment);
    9168     } while (0);
    9169 
    9170     if (RT_UNLIKELY(fLockRead))
    9171     {
    9172         rc2 = vdThreadFinishRead(pDisk);
    9173         AssertRC(rc2);
    9174     }
     9141    /* sanity check */
     9142    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9143    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9144
     9145    /* Check arguments. */
     9146    AssertPtrReturn(pszComment, VERR_INVALID_POINTER);
     9147    AssertReturn(cbComment > 0, VERR_INVALID_PARAMETER);
     9148
     9149    /* Do the job. */
     9150    int rc2 = vdThreadStartRead(pDisk);
     9151    AssertRC(rc2);
     9152
     9153    int rc;
     9154    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9155    AssertPtr(pImage);
     9156    if (pImage)
     9157        rc = pImage->Backend->pfnGetComment(pImage->pBackendData, pszComment, cbComment);
     9158    else
     9159        rc = VERR_VD_IMAGE_NOT_FOUND;
     9160
     9161    rc2 = vdThreadFinishRead(pDisk);
     9162    AssertRC(rc2);
    91759163
    91769164    LogFlowFunc(("returns %Rrc, pszComment=\"%s\"\n", rc, pszComment));
     
    91829170                               const char *pszComment)
    91839171{
    9184     int rc;
    9185     int rc2;
    9186     bool fLockWrite = false;
    9187 
    91889172    LogFlowFunc(("pDisk=%#p nImage=%u pszComment=%#p \"%s\"\n",
    91899173                 pDisk, nImage, pszComment, pszComment));
    9190     do
    9191     {
    9192         /* sanity check */
    9193         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9194         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9195 
    9196         /* Check arguments. */
    9197         AssertMsgBreakStmt(VALID_PTR(pszComment) || pszComment == NULL,
    9198                            ("pszComment=%#p \"%s\"\n", pszComment, pszComment),
    9199                            rc = VERR_INVALID_PARAMETER);
    9200 
    9201         rc2 = vdThreadStartWrite(pDisk);
    9202         AssertRC(rc2);
    9203         fLockWrite = true;
    9204 
    9205         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9206         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9207 
     9174    /* sanity check */
     9175    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9176    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9177
     9178    /* Check arguments. */
     9179    AssertPtrNullReturn(pszComment, VERR_INVALID_POINTER);
     9180
     9181    /* Do the job. */
     9182    int rc2 = vdThreadStartWrite(pDisk);
     9183    AssertRC(rc2);
     9184
     9185    int rc;
     9186    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9187    AssertPtr(pImage);
     9188    if (pImage)
    92089189        rc = pImage->Backend->pfnSetComment(pImage->pBackendData, pszComment);
    9209     } while (0);
    9210 
    9211     if (RT_UNLIKELY(fLockWrite))
    9212     {
    9213         rc2 = vdThreadFinishWrite(pDisk);
    9214         AssertRC(rc2);
    9215     }
     9190    else
     9191        rc = VERR_VD_IMAGE_NOT_FOUND;
     9192
     9193    rc2 = vdThreadFinishWrite(pDisk);
     9194    AssertRC(rc2);
    92169195
    92179196    LogFlowFunc(("returns %Rrc\n", rc));
     
    92229201VBOXDDU_DECL(int) VDGetUuid(PVDISK pDisk, unsigned nImage, PRTUUID pUuid)
    92239202{
     9203    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid));
     9204    /* sanity check */
     9205    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9206    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9207
     9208    /* Check arguments. */
     9209    AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9210
     9211    /* Do the job. */
     9212    int rc2 = vdThreadStartRead(pDisk);
     9213    AssertRC(rc2);
     9214
    92249215    int rc;
    9225     int rc2;
    9226     bool fLockRead = false;
    9227 
    9228     LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid));
    9229     do
    9230     {
    9231         /* sanity check */
    9232         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9233         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9234 
    9235         /* Check arguments. */
    9236         AssertMsgBreakStmt(VALID_PTR(pUuid),
    9237                            ("pUuid=%#p\n", pUuid),
    9238                            rc = VERR_INVALID_PARAMETER);
    9239 
    9240         rc2 = vdThreadStartRead(pDisk);
    9241         AssertRC(rc2);
    9242         fLockRead = true;
    9243 
    9244         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9245         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9246 
     9216    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9217    AssertPtr(pImage);
     9218    if (pImage)
    92479219        rc = pImage->Backend->pfnGetUuid(pImage->pBackendData, pUuid);
    9248     } while (0);
    9249 
    9250     if (RT_UNLIKELY(fLockRead))
    9251     {
    9252         rc2 = vdThreadFinishRead(pDisk);
    9253         AssertRC(rc2);
    9254     }
     9220    else
     9221        rc = VERR_VD_IMAGE_NOT_FOUND;
     9222
     9223    rc2 = vdThreadFinishRead(pDisk);
     9224    AssertRC(rc2);
    92559225
    92569226    LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid));
     
    92619231VBOXDDU_DECL(int) VDSetUuid(PVDISK pDisk, unsigned nImage, PCRTUUID pUuid)
    92629232{
    9263     int rc;
    9264     int rc2;
    9265     bool fLockWrite = false;
    9266 
    92679233    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n",
    92689234                 pDisk, nImage, pUuid, pUuid));
    9269     do
    9270     {
    9271         /* sanity check */
    9272         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9273         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9274 
    9275         AssertMsgBreakStmt(VALID_PTR(pUuid) || pUuid == NULL,
    9276                            ("pUuid=%#p\n", pUuid),
    9277                            rc = VERR_INVALID_PARAMETER);
    9278 
    9279         rc2 = vdThreadStartWrite(pDisk);
    9280         AssertRC(rc2);
    9281         fLockWrite = true;
    9282 
    9283         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9284         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9285 
    9286         RTUUID Uuid;
    9287         if (!pUuid)
    9288         {
    9289             RTUuidCreate(&Uuid);
    9290             pUuid = &Uuid;
    9291         }
     9235    /* sanity check */
     9236    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9237    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9238
     9239    /* Check arguments. */
     9240    RTUUID Uuid;
     9241    if (pUuid)
     9242        AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9243    else
     9244    {
     9245        int rc = RTUuidCreate(&Uuid);
     9246        AssertRCReturn(rc, rc);
     9247        pUuid = &Uuid;
     9248    }
     9249
     9250    /* Do the job. */
     9251    int rc2 = vdThreadStartWrite(pDisk);
     9252    AssertRC(rc2);
     9253
     9254    int rc;
     9255    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9256    AssertPtr(pImage);
     9257    if (pImage)
    92929258        rc = pImage->Backend->pfnSetUuid(pImage->pBackendData, pUuid);
    9293     } while (0);
    9294 
    9295     if (RT_UNLIKELY(fLockWrite))
    9296     {
    9297         rc2 = vdThreadFinishWrite(pDisk);
    9298         AssertRC(rc2);
    9299     }
     9259    else
     9260        rc = VERR_VD_IMAGE_NOT_FOUND;
     9261
     9262    rc2 = vdThreadFinishWrite(pDisk);
     9263    AssertRC(rc2);
    93009264
    93019265    LogFlowFunc(("returns %Rrc\n", rc));
     
    93069270VBOXDDU_DECL(int) VDGetModificationUuid(PVDISK pDisk, unsigned nImage, PRTUUID pUuid)
    93079271{
    9308     int rc = VINF_SUCCESS;
    9309     int rc2;
    9310     bool fLockRead = false;
    9311 
    93129272    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p\n", pDisk, nImage, pUuid));
    9313     do
    9314     {
    9315         /* sanity check */
    9316         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9317         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9318 
    9319         /* Check arguments. */
    9320         AssertMsgBreakStmt(VALID_PTR(pUuid),
    9321                            ("pUuid=%#p\n", pUuid),
    9322                            rc = VERR_INVALID_PARAMETER);
    9323 
    9324         rc2 = vdThreadStartRead(pDisk);
    9325         AssertRC(rc2);
    9326         fLockRead = true;
    9327 
    9328         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9329         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9330 
    9331         rc = pImage->Backend->pfnGetModificationUuid(pImage->pBackendData,
    9332                                                      pUuid);
    9333     } while (0);
    9334 
    9335     if (RT_UNLIKELY(fLockRead))
    9336     {
    9337         rc2 = vdThreadFinishRead(pDisk);
    9338         AssertRC(rc2);
    9339     }
     9273    /* sanity check */
     9274    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9275    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9276
     9277    /* Check arguments. */
     9278    AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9279
     9280    /* Do the job. */
     9281    int rc2 = vdThreadStartRead(pDisk);
     9282    AssertRC(rc2);
     9283
     9284    int rc;
     9285    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9286    AssertPtr(pImage);
     9287    if (pImage)
     9288        rc = pImage->Backend->pfnGetModificationUuid(pImage->pBackendData, pUuid);
     9289    else
     9290        rc = VERR_VD_IMAGE_NOT_FOUND;
     9291
     9292    rc2 = vdThreadFinishRead(pDisk);
     9293    AssertRC(rc2);
    93409294
    93419295    LogFlowFunc(("returns %Rrc, Uuid={%RTuuid}\n", rc, pUuid));
     
    93469300VBOXDDU_DECL(int) VDSetModificationUuid(PVDISK pDisk, unsigned nImage, PCRTUUID pUuid)
    93479301{
    9348     int rc;
    9349     int rc2;
    9350     bool fLockWrite = false;
    9351 
    93529302    LogFlowFunc(("pDisk=%#p nImage=%u pUuid=%#p {%RTuuid}\n",
    93539303                 pDisk, nImage, pUuid, pUuid));
    9354     do
    9355     {
    9356         /* sanity check */
    9357         AssertPtrBreakStmt(pDisk, rc = VERR_INVALID_PARAMETER);
    9358         AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
    9359 
    9360         /* Check arguments. */
    9361         AssertMsgBreakStmt(VALID_PTR(pUuid) || pUuid == NULL,
    9362                            ("pUuid=%#p\n", pUuid),
    9363                            rc = VERR_INVALID_PARAMETER);
    9364 
    9365         rc2 = vdThreadStartWrite(pDisk);
    9366         AssertRC(rc2);
    9367         fLockWrite = true;
    9368 
    9369         PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
    9370         AssertPtrBreakStmt(pImage, rc = VERR_VD_IMAGE_NOT_FOUND);
    9371 
    9372         RTUUID Uuid;
    9373         if (!pUuid)
    9374         {
    9375             RTUuidCreate(&Uuid);
    9376             pUuid = &Uuid;
    9377         }
    9378         rc = pImage->Backend->pfnSetModificationUuid(pImage->pBackendData,
    9379                                                      pUuid);
    9380     } while (0);
    9381 
    9382     if (RT_UNLIKELY(fLockWrite))
    9383     {
    9384         rc2 = vdThreadFinishWrite(pDisk);
    9385         AssertRC(rc2);
    9386     }
     9304    /* sanity check */
     9305    AssertPtrReturn(pDisk, VERR_INVALID_POINTER);
     9306    AssertMsg(pDisk->u32Signature == VDISK_SIGNATURE, ("u32Signature=%08x\n", pDisk->u32Signature));
     9307
     9308    /* Check arguments. */
     9309    RTUUID Uuid;
     9310    if (pUuid)
     9311        AssertPtrReturn(pUuid, VERR_INVALID_POINTER);
     9312    else
     9313    {
     9314        int rc = RTUuidCreate(&Uuid);
     9315        AssertRCReturn(rc, rc);
     9316        pUuid = &Uuid;
     9317    }
     9318
     9319    /* Do the job. */
     9320    int rc2 = vdThreadStartWrite(pDisk);
     9321    AssertRC(rc2);
     9322
     9323    int rc;
     9324    PVDIMAGE pImage = vdGetImageByNumber(pDisk, nImage);
     9325    if (pImage)
     9326        rc = pImage->Backend->pfnSetModificationUuid(pImage->pBackendData, pUuid);
     9327    else
     9328        rc = VERR_VD_IMAGE_NOT_FOUND;
     9329
     9330    rc2 = vdThreadFinishWrite(pDisk);
     9331    AssertRC(rc2);
    93879332
    93889333    LogFlowFunc(("returns %Rrc\n", rc));
Note: See TracChangeset for help on using the changeset viewer.

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