summaryrefslogtreecommitdiff
path: root/src/journal/test-compress-benchmark.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-10-18 17:59:40 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2015-10-23 09:44:16 -0400
commit0036b0bf2d54d2acf7e8dda2d47fe4cf2123da0a (patch)
tree3abfb86070326fc6a23708a2299cd712759dba19 /src/journal/test-compress-benchmark.c
parentc4291c1524ee4e4575c3b0a726ca5507b2ba74f3 (diff)
downloadsystemd-0036b0bf2d54d2acf7e8dda2d47fe4cf2123da0a.tar.gz
test-compress-benchmark: properly initialize buffer
We were compressing unitialized memory, which should not result in any problems, but is inelegant.
Diffstat (limited to 'src/journal/test-compress-benchmark.c')
-rw-r--r--src/journal/test-compress-benchmark.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c
index 385c85e5b9..782b85db26 100644
--- a/src/journal/test-compress-benchmark.c
+++ b/src/journal/test-compress-benchmark.c
@@ -64,11 +64,18 @@ static char* make_buf(size_t count, const char *type) {
for (i = 0; i < count; i++)
buf[i] = 'a' + i % ('z' - 'a' + 1);
else if (streq(type, "random")) {
- random_bytes(buf, count/10);
- random_bytes(buf + 2*count/10, count/10);
- random_bytes(buf + 4*count/10, count/20);
- random_bytes(buf + 6*count/10, count/20);
- random_bytes(buf + 8*count/10, count/20);
+ size_t step = count / 10;
+
+ random_bytes(buf, step);
+ memzero(buf + 1*step, step);
+ random_bytes(buf + 2*step, step);
+ memzero(buf + 3*step, step);
+ random_bytes(buf + 4*step, step);
+ memzero(buf + 5*step, step);
+ random_bytes(buf + 6*step, step);
+ memzero(buf + 7*step, step);
+ random_bytes(buf + 8*step, step);
+ memzero(buf + 9*step, step);
} else
assert_not_reached("here");