Changeset 103108 in vbox for trunk/src/VBox/Runtime/common/fs/fatvfs.cpp
- Timestamp:
- Jan 29, 2024 3:44:44 PM (10 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/fatvfs.cpp
r103005 r103108 926 926 uint64_t off = UINT64_MAX; 927 927 uint64_t offEdge = UINT64_MAX; 928 RTSGSEG aSgSegs[8]; 929 RT_ZERO(aSgSegs); /* Initialization required for GCC >= 11. */ 930 RTSGBUF SgBuf; 931 RTSgBufInit(&SgBuf, aSgSegs, RT_ELEMENTS(aSgSegs)); 932 SgBuf.cSegs = 0; /** @todo RTSgBuf API is stupid, make it smarter. */ 928 unsigned cSegs = 0; 929 RTSGSEG aSgSegs[8] /* Initialization required for GCC >= 11. */ 930 = { { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, { NULL, 0 }, }; 933 931 934 932 for (uint32_t iFatCopy = 0; iFatCopy < pThis->cFats; iFatCopy++) … … 955 953 && offEntry) 956 954 { 957 Assert( SgBuf.cSegs > 0);958 Assert( (uintptr_t)aSgSegs[ SgBuf.cSegs - 1].pvSeg + aSgSegs[SgBuf.cSegs - 1].cbSeg955 Assert(cSegs > 0); 956 Assert( (uintptr_t)aSgSegs[cSegs - 1].pvSeg + aSgSegs[cSegs - 1].cbSeg 959 957 == (uintptr_t)&pFatCache->aEntries[iEntry].pbData[offEntry]); 960 aSgSegs[ SgBuf.cSegs - 1].cbSeg += pFatCache->cbDirtyLine;958 aSgSegs[cSegs - 1].cbSeg += pFatCache->cbDirtyLine; 961 959 offEdge += pFatCache->cbDirtyLine; 962 960 } … … 967 965 { 968 966 off = offDirtyLine; 969 Assert( SgBuf.cSegs == 0);967 Assert(cSegs == 0); 970 968 } 971 969 /* flush if not adjacent or if we're out of segments. */ 972 970 else if ( offDirtyLine != offEdge 973 || SgBuf.cSegs >= RT_ELEMENTS(aSgSegs))971 || cSegs >= RT_ELEMENTS(aSgSegs)) 974 972 { 975 RTSgBufReset(&SgBuf); 973 RTSGBUF SgBuf; 974 RTSgBufInit(&SgBuf, aSgSegs, cSegs); 976 975 int rc2 = RTVfsFileSgWrite(pThis->hVfsBacking, off, &SgBuf, true /*fBlocking*/, NULL); 977 976 if (RT_FAILURE(rc2) && RT_SUCCESS(rc)) 978 977 rc = rc2; 979 SgBuf.cSegs = 0;980 off = offDirtyLine;978 cSegs = 0; 979 off = offDirtyLine; 981 980 } 982 981 983 982 /* Append segment. */ 984 aSgSegs[ SgBuf.cSegs].cbSeg = pFatCache->cbDirtyLine;985 aSgSegs[ SgBuf.cSegs].pvSeg = &pFatCache->aEntries[iEntry].pbData[offEntry];986 SgBuf.cSegs++;983 aSgSegs[cSegs].cbSeg = pFatCache->cbDirtyLine; 984 aSgSegs[cSegs].pvSeg = &pFatCache->aEntries[iEntry].pbData[offEntry]; 985 cSegs++; 987 986 offEdge = offDirtyLine + pFatCache->cbDirtyLine; 988 987 } … … 1003 1002 * Final flush job. 1004 1003 */ 1005 if (SgBuf.cSegs > 0) 1006 { 1007 RTSgBufReset(&SgBuf); 1004 if (cSegs > 0) 1005 { 1006 RTSGBUF SgBuf; 1007 RTSgBufInit(&SgBuf, aSgSegs, cSegs); 1008 1008 int rc2 = RTVfsFileSgWrite(pThis->hVfsBacking, off, &SgBuf, true /*fBlocking*/, NULL); 1009 1009 if (RT_FAILURE(rc2) && RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.