HomeFreeBSD

Add assertion and make variables unsigned in abd_alloc_chunks()

Description

Add assertion and make variables unsigned in abd_alloc_chunks()

Clang's static analyzer pointed out that if alloc_pages >= nr_pages
before the loop, the value of page will be undefined and will be used
anyway. This should not be possible, but as cleanup, we add an
assertion. We also recognize that the local variables should be unsigned
in the first place, so we make them unsigned. This is not enough to
avoid the need for the assertion, since there is still the case that
alloc_pages == nr_pages and nr_pages == 0, which the assertion
implicitly checks.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14456

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Feb 2 2023, 10:30 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Feb 6 2023, 7:10 PM
Parents
rGcfb49616cdeb: Cleanup: spa vdev processing should check NULL pointers
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG66953686c059: Add assertion and make variables unsigned in abd_alloc_chunks() (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Feb 6 2023, 7:10 PM