[bb] fix rand() initialization

* What do you know, srand() is thread-local...
This commit is contained in:
Pete Batard 2016-11-29 11:02:02 +00:00
parent cbf01071ab
commit 8128d34e35
3 changed files with 7 additions and 6 deletions

View file

@ -349,6 +349,7 @@ static void pattern_fill(unsigned char *buffer, unsigned int pattern,
unsigned char bpattern[sizeof(pattern)], *ptr;
if (pattern == (unsigned int) ~0) {
srand((unsigned int)_GetTickCount64());
for (ptr = buffer; ptr < buffer + n; ptr++) {
// coverity[dont_call]
(*ptr) = rand() % (1 << (8 * sizeof(char)));
@ -450,6 +451,7 @@ static unsigned int test_rw(HANDLE hDrive, blk_t last_block, size_t block_size,
cur_pattern = 0;
for (pat_idx = 0; pat_idx < nb_passes; pat_idx++) {
srand((unsigned int)_GetTickCount64());
if (cancel_ops) goto out;
// coverity[dont_call]
id_offset = rand() * (block_size-sizeof(blk_t)) / RAND_MAX;