From: Zbigniew Jędrzejewski-Szmek Date: Sun, 18 Oct 2015 21:59:40 +0000 (-0400) Subject: test-compress-benchmark: properly initialize buffer X-Git-Tag: v228~160^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F1653%2Fhead;p=thirdparty%2Fsystemd.git test-compress-benchmark: properly initialize buffer We were compressing unitialized memory, which should not result in any problems, but is inelegant. --- diff --git a/src/journal/test-compress-benchmark.c b/src/journal/test-compress-benchmark.c index 385c85e5b97..782b85db261 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");