VirtualBox

Ignore:
Timestamp:
Sep 13, 2023 2:20:04 PM (17 months ago)
Author:
vboxsync
Message:

IPRT: Fixing assertions (from r158845) related to VFS pfnRead/pfnWrite operations.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/vfs/vfsbase.cpp

    r100908 r101108  
    36163616    int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbRead);
    36173617    RTVfsLockReleaseWrite(pThis->Base.hLock);
    3618     Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(&SgBuf));
     3618
     3619    Assert(   rc != VINF_SUCCESS
     3620           || RTSgBufIsAtEnd(&SgBuf)
     3621           || (pcbRead && cbToRead == *pcbRead + RTSgBufCalcLengthLeft(&SgBuf)));
     3622    Assert(!pcbRead || *pcbRead + RTSgBufCalcLengthLeft(&SgBuf) == cbToRead || RT_FAILURE(rc));
    36193623    return rc;
    36203624}
     
    36403644    int rc = pThis->pOps->pfnRead(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbRead);
    36413645    RTVfsLockReleaseWrite(pThis->Base.hLock);
    3642     Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(&SgBuf));
     3646
     3647    Assert(   rc != VINF_SUCCESS
     3648           || RTSgBufIsAtEnd(&SgBuf)
     3649           || (pcbRead && cbToRead == *pcbRead + RTSgBufCalcLengthLeft(&SgBuf)));
     3650    Assert(!pcbRead || *pcbRead + RTSgBufCalcLengthLeft(&SgBuf) == cbToRead || RT_FAILURE(rc));
    36433651    return rc;
    36443652}
     
    36663674        rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, -1 /*off*/, &SgBuf, fBlocking, pcbWritten);
    36673675        RTVfsLockReleaseWrite(pThis->Base.hLock);
     3676
    36683677        Assert(!pcbWritten || *pcbWritten + RTSgBufCalcLengthLeft(&SgBuf) == cbToWrite || RT_FAILURE(rc));
    36693678    }
     
    36963705        rc = pThis->pOps->pfnWrite(pThis->Base.pvThis, off, &SgBuf, fBlocking, pcbWritten);
    36973706        RTVfsLockReleaseWrite(pThis->Base.hLock);
     3707
    36983708        Assert(!pcbWritten || *pcbWritten + RTSgBufCalcLengthLeft(&SgBuf) == cbToWrite || RT_FAILURE(rc));
    36993709    }
     
    37153725    AssertReturn(fBlocking || pcbRead, VERR_INVALID_PARAMETER);
    37163726    AssertReturn(pThis->fFlags & RTFILE_O_READ, VERR_ACCESS_DENIED);
     3727#ifdef RT_STRICT
     3728    size_t const cbToReadAssert = RTSgBufCalcLengthLeft(pSgBuf);
     3729#endif
    37173730
    37183731    RTVfsLockAcquireWrite(pThis->Base.hLock);
     
    37483761    }
    37493762    RTVfsLockReleaseWrite(pThis->Base.hLock);
    3750     Assert(rc != VINF_SUCCESS || RTSgBufIsAtEnd(pSgBuf));
     3763
     3764    Assert(   rc != VINF_SUCCESS
     3765           || RTSgBufIsAtEnd(pSgBuf)
     3766           || (pcbRead && cbToReadAssert == *pcbRead + RTSgBufCalcLengthLeft(pSgBuf)));
     3767    Assert(!pcbRead || *pcbRead + RTSgBufCalcLengthLeft(pSgBuf) == cbToReadAssert || RT_FAILURE(rc));
    37513768    return rc;
    37523769}
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