If the first call to `loop_read()` returns 0 (no input), `total_in`
remains 0, causing `total_out/total_in` to potential divide by zero.
We add a check before logging the compression ratio to skip the
percentage calculation when total_in is zero.
Co-authored-by: jinyaoguo <guo846@purdue.edu>
(cherry picked from commit
2584f745e0509472e68449bd81c60c26056d514a)
(cherry picked from commit
18a42e321d699e7f3ae46930fa070228d02774ed)
if (ret_uncompressed_size)
*ret_uncompressed_size = total_in;
- log_debug("LZ4 compression finished (%" PRIu64 " -> %" PRIu64 " bytes, %.1f%%)",
- total_in, total_out,
- (double) total_out / total_in * 100);
+ if (total_in == 0)
+ log_debug("LZ4 compression finished (no input data)");
+ else
+ log_debug("LZ4 compression finished (%" PRIu64 " -> %" PRIu64 " bytes, %.1f%%)",
+ total_in, total_out,
+ (double) total_out / total_in * 100);
return 0;
#else