From 2504834861416f62a41d5bf3a8f5fa42fd73d144 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 28 Nov 2017 13:11:35 +0100 Subject: [PATCH] journal: avoid undefined behaviour in float division by 0.0 Coverity says that's undefined. I'm pretty sure we always would get a nan, but let's avoid (formally) undefined behaviour since that can cause compilers to do strange things. --- src/journal/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/journal/compress.c b/src/journal/compress.c index a659459..92eb387 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -667,7 +667,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) { log_debug("LZ4 decompression finished (%zu -> %zu bytes, %.1f%%)", total_in, total_out, - (double) total_out / total_in * 100); + total_in > 0 ? (double) total_out / total_in * 100 : 0.0); cleanup: munmap(src, st.st_size); return r; -- 2.7.4