Skip to content

Commit 9fa65ae

Browse files
authored
Correctly randomize value buffer (#172)
1 parent 01f3b1a commit 9fa65ae

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

obj_gen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,20 @@ void object_generator::alloc_value_buffer(void)
244244
char *d = m_value_buffer;
245245
int ret;
246246
int iter = 0;
247-
248247
while (d - m_value_buffer < size) {
249248
if (buf1_idx == sizeof(buf1)) {
250249
buf1_idx = 0;
251250
buf2_idx++;
251+
252252
if (buf2_idx >= sizeof(buf2)) {
253-
iter++;
254-
if (iter == 20) {
253+
if (iter % 20 == 0) {
255254
ret = read(m_random_fd, buf1, sizeof(buf1));
256255
assert(ret > -1);
257256
ret = read(m_random_fd, buf2, sizeof(buf2));
258257
assert(ret > -1);
259-
buf1_idx = buf2_idx = iter = 0;
260258
}
259+
buf2_idx = 0;
260+
iter++;
261261
}
262262
}
263263
*d = buf1[buf1_idx] ^ buf2[buf2_idx] ^ iter;

0 commit comments

Comments
 (0)