mirror of
https://github.com/amadvance/snapraid.git
synced 2026-10-25 18:40:19 -04:00
Removes rand() use from the raid module.
This commit is contained in:
parent
0a68d357e3
commit
95e4ed03bf
5 changed files with 14 additions and 15 deletions
|
|
@ -1588,11 +1588,6 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr)
|
|||
return ptr;
|
||||
}
|
||||
|
||||
void mrand_vector(int n, size_t size, void** vv)
|
||||
{
|
||||
raid_mrand_vector(n, size, vv);
|
||||
}
|
||||
|
||||
void mtest_vector(int n, size_t size, void** vv)
|
||||
{
|
||||
if (raid_mtest_vector(n, size, vv) != 0) {
|
||||
|
|
|
|||
|
|
@ -485,7 +485,7 @@ void** malloc_nofail_vector_align(int nd, int n, size_t size, void** freeptr);
|
|||
/**
|
||||
* Fills the memory vector with random data.
|
||||
*/
|
||||
void mrand_vector(int n, size_t size, void** vv);
|
||||
void mrand_vector(unsigned seed, int n, size_t size, void** vv);
|
||||
|
||||
/**
|
||||
* Tests the memory vector for RAM problems.
|
||||
|
|
|
|||
|
|
@ -68,15 +68,19 @@ void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr)
|
|||
return v;
|
||||
}
|
||||
|
||||
void raid_mrand_vector(int n, size_t size, void **vv)
|
||||
void raid_mrand_vector(unsigned seed, int n, size_t size, void **vv)
|
||||
{
|
||||
unsigned char **v = (unsigned char**)vv;
|
||||
int i;
|
||||
size_t j;
|
||||
|
||||
for (i = 0; i < n; ++i)
|
||||
for (j = 0; j < size; ++j)
|
||||
v[i][j] = rand();
|
||||
for (j = 0; j < size; ++j) {
|
||||
/* basic C99/C11 linear congruential generator */
|
||||
seed = seed * 1103515245U + 12345U;
|
||||
|
||||
v[i][j] = seed >> 16;
|
||||
}
|
||||
}
|
||||
|
||||
int raid_mtest_vector(int n, size_t size, void **vv)
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ void *raid_malloc_align(size_t size, void **freeptr);
|
|||
void **raid_malloc_vector(int nd, int n, size_t size, void **freeptr);
|
||||
|
||||
/**
|
||||
* Fills the memory vector with random data.
|
||||
* Fills the memory vector with pseudo-random data based on the specified seed.
|
||||
*/
|
||||
void raid_mrand_vector(int n, size_t size, void **vv);
|
||||
void raid_mrand_vector(unsigned seed, int n, size_t size, void **vv);
|
||||
|
||||
/**
|
||||
* Tests the memory vector for RAM problems.
|
||||
|
|
|
|||
|
|
@ -176,8 +176,8 @@ int raid_test_rec(int mode, int nd, size_t size)
|
|||
|
||||
waste = v[nv - 1];
|
||||
|
||||
/* fill data disk with random */
|
||||
raid_mrand_vector(nd, size, v);
|
||||
/* fill with pseudo-random data with the arbitrary seed "1" */
|
||||
raid_mrand_vector(1, nd, size, v);
|
||||
|
||||
/* setup recov functions */
|
||||
for (i = 0; i < np; ++i) {
|
||||
|
|
@ -304,8 +304,8 @@ int raid_test_par(int mode, int nd, size_t size)
|
|||
if (raid_mtest_vector(nv, size, v) != 0)
|
||||
goto bail;
|
||||
|
||||
/* fill with random */
|
||||
raid_mrand_vector(nv, size, v);
|
||||
/* fill with pseudo-random data with the arbitrary seed "2" */
|
||||
raid_mrand_vector(2, nv, size, v);
|
||||
|
||||
/* compute the parity */
|
||||
raid_gen_ref(nd, np, size, v);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue