From: Zbigniew Jędrzejewski-Szmek Date: Tue, 28 Nov 2017 12:11:35 +0000 (+0100) Subject: journal: avoid undefined behaviour in float division by 0.0 X-Git-Tag: v236~99^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2504834861416f62a41d5bf3a8f5fa42fd73d144;p=platform%2Fupstream%2Fsystemd.git 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. --- 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;