]> git.proxmox.com Git - mirror_zfs.git/commit
Address warnings about possible division by zero from clangsa
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Thu, 3 Nov 2022 16:58:14 +0000 (12:58 -0400)
committerTony Hutter <hutter2@llnl.gov>
Thu, 1 Dec 2022 20:39:43 +0000 (12:39 -0800)
commit256b74d0b034ff61709fca64d58f81746186eaef
treef007e8b1a23d999d0b18883c7cd8674286150b0a
parentac01b876c91ea6dbbb75775db5603077f3490f0b
Address warnings about possible division by zero from clangsa

* The complaint in ztest_replay_write() is only possible if something
   went horribly wrong. An assertion will silence this and if it goes
   off, we will know that something is wrong.
 * The complaint in spa_estimate_metaslabs_to_flush() is not impossible,
   but seems very unlikely. We resolve this by passing the value from
   the `MIN()` that does not go to infinity when the variable is zero.

There was a third report from Clang's scan-build, but that was a
definite false positive and disappeared when checked again through
Clang's static analyzer with Z3 refution via CodeChecker.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14124
cmd/ztest/ztest.c
module/zfs/spa_log_spacemap.c