VirtualBox

Ignore:
Timestamp:
May 5, 2023 1:44:46 PM (20 months ago)
Author:
vboxsync
Message:

testcase/tstGuestCtrlParseBuffer: Simplified determining reading chunk sizes a bit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/testcase/tstGuestCtrlParseBuffer.cpp

    r99393 r99640  
    216216    size_t cBlocks = 0;
    217217
    218     unsigned aToRead[] = { 256, 23, 13 };
    219     unsigned i = 0;
     218    unsigned aToRead[] = { 256, 23, 13 }; /* Array of certain read amounts to check for in a sequence. */
     219    unsigned idxToRead = 0; /* Index within aToRead. */
    220220
    221221    uint64_t cbToRead = cbFileSize;
     
    226226        do
    227227        {
    228             size_t cbChunk = RT_MIN(cbToRead, i < RT_ELEMENTS(aToRead) ? aToRead[i++] : RTRandU64Ex(8, RT_MIN(sizeof(buf), 64)));
    229             if (cbChunk > cbToRead)
    230                 cbChunk = cbToRead;
     228            size_t       cbChunk           = cbToRead;
     229            size_t const cbToReadFromArray = idxToRead < RT_ELEMENTS(aToRead) ? aToRead[idxToRead++] : 0;
     230            if (cbToReadFromArray)
     231                cbChunk = RT_MIN(cbChunk, cbToReadFromArray);
     232            cbChunk = RT_MIN(cbChunk, RTRandU64Ex(8, RT_MIN(sizeof(buf), 64)));
    231233            if (cbChunk)
    232234            {
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