projects
/
fio.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
t/dedupe: use generic blockdev_size() to get size
[fio.git]
/
lib
/
rand.c
diff --git
a/lib/rand.c
b/lib/rand.c
index 66d04729a49eaa073f822d77a93b66ae426f659d..a79fb9c17c321a94e8e4bcfe030193003c80d93f 100644
(file)
--- a/
lib/rand.c
+++ b/
lib/rand.c
@@
-34,7
+34,6
@@
*/
#include <string.h>
*/
#include <string.h>
-#include <assert.h>
#include "rand.h"
#include "../hash.h"
#include "rand.h"
#include "../hash.h"
@@
-95,10
+94,16
@@
unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf,
unsigned int percentage,
unsigned int segment, unsigned int len)
{
unsigned int percentage,
unsigned int segment, unsigned int len)
{
- unsigned int this_len, rep_len;
unsigned long r = __rand(fs);
unsigned long r = __rand(fs);
+ unsigned int this_len;
- assert(segment <= len);
+ if (percentage == 100) {
+ memset(buf, 0, len);
+ return 0;
+ }
+
+ if (segment > len)
+ segment = len;
if (sizeof(int) != sizeof(long *))
r *= (unsigned long) __rand(fs);
if (sizeof(int) != sizeof(long *))
r *= (unsigned long) __rand(fs);
@@
-116,16
+121,12
@@
unsigned long fill_random_buf_percentage(struct frand_state *fs, void *buf,
len -= this_len;
buf += this_len;
len -= this_len;
buf += this_len;
- /*
- * Now duplicate random chunk in rest of buf
- */
- rep_len = segment - this_len;
- if (rep_len > len)
- rep_len = len;
+ if (this_len > len)
+ this_len = len;
- mem
cpy(buf, buf + rep_len, rep
_len);
-
buf += rep
_len;
-
len -= rep
_len;
+ mem
set(buf, 0, this
_len);
+
len -= this
_len;
+
buf += this
_len;
}
return r;
}
return r;