VirtualBox

Changeset 62796 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 1, 2016 9:09:20 AM (8 years ago)
Author:
vboxsync
Message:

RTDirCreateUniqueNumbered: Don't depend on uint64_t wrap around.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/generic/RTDirCreateUniqueNumbered-generic.cpp

    r62723 r62796  
    111111
    112112        Assert(cbLeft > cchDigits);
    113         uint64_t iSeq = UINT64_MAX;
    114113        for (uint32_t iTry = 0; iTry <= cMaxTries; iTry++)
    115114        {
    116115            /* Try sequentially first for a little bit, then switch to random numbers. */
     116            uint64_t iSeq;
    117117            if (iTry > 20)
    118118                iSeq = RTRandU64Ex(0, uEndSeq);
    119119            else
    120120            {
    121                 iSeq++;
    122                 if (iSeq < UINT64_MAX)
     121                iSeq = iTry;
     122                if (uEndSeq < UINT64_MAX)
    123123                    iSeq %= uEndSeq + 1;
    124124            }
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