diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-08-27 14:02:33 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-08-27 18:20:34 +0900 |
commit | 89d36ce8f73990959032b78d1afb939cd6b5e843 (patch) | |
tree | 2d809c6c6af904c61c1e1d7593c8ea82adf5b76e /src/journal | |
parent | 8062e643e62387895ea9c3243aeca7c7a894fcd1 (diff) | |
download | systemd-89d36ce8f73990959032b78d1afb939cd6b5e843.tar.gz |
journal: fix divide-by-zero warning
Fixes CID#1430209.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/compress.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/journal/compress.c b/src/journal/compress.c index a59c2b7a88..852f9e07ba 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 |