HomeFreeBSD

Suppress Clang Static Analyzer warning in vdev_split()

Description

Suppress Clang Static Analyzer warning in vdev_split()

Clang's static analyzer pointed out that we can have a NULL pointer
dereference if we ever attempt to split a vdev that has only 1 child. If
that happens, we are left with zero children, but then try to access a
non-existent child. Calling vdev_split() on a vdev with only 1 child
should be impossible due to how the code is structured. If this ever
happens, it would be best to stop execution immediately even in a
production environment to allow for the best possible chance of recovery
by an expert, so we use VERIFY3U() instead of ASSERT3U().

Unfortunately, while that defensive assertion will prevent execution
from ever reaching the NULL pointer dereference, Clang's static analyzer
does not realize that, so we add an ASSERT() to inform it of this.

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

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Mar 4 2023, 8:38 PM
Brian Behlendorf <behlendorf1@llnl.gov>Committed on Mar 8 2023, 9:51 PM
Parents
rG0b831cabc6e5: Suppress Clang Static Analyzer warning about SNPRINTF_BLKPTR()
Branches
Unknown
Tags
Unknown

Event Timeline

Brian Behlendorf <behlendorf1@llnl.gov> committed rG399bb8160705: Suppress Clang Static Analyzer warning in vdev_split() (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Mar 8 2023, 9:51 PM