From: Yu Watanabe Date: Thu, 27 Aug 2020 05:02:33 +0000 (+0900) Subject: journal: fix divide-by-zero warning X-Git-Tag: v247-rc1~351^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=89d36ce8f73990959032b78d1afb939cd6b5e843;p=thirdparty%2Fsystemd.git journal: fix divide-by-zero warning Fixes CID#1430209. --- diff --git a/src/journal/compress.c b/src/journal/compress.c index a59c2b7a883..852f9e07bab 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -927,11 +927,12 @@ int compress_stream_zstd(int fdf, int fdt, uint64_t max_bytes) { break; } - log_debug( - "ZSTD compression finished (%" PRIu64 " -> %" PRIu64 " bytes, %.1f%%)", - in_bytes, - max_bytes - left, - (double) (max_bytes - left) / in_bytes * 100); + if (in_bytes > 0) + log_debug("ZSTD compression finished (%" PRIu64 " -> %" PRIu64 " bytes, %.1f%%)", + in_bytes, max_bytes - left, (double) (max_bytes - left) / in_bytes * 100); + else + log_debug("ZSTD compression finished (%" PRIu64 " -> %" PRIu64 " bytes)", + in_bytes, max_bytes - left); return 0; #else