Page MenuHomeFreeBSD

rb_tree: silence coverity
ClosedPublic

Authored by dougm on Jun 30 2022, 7:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 21 2024, 4:44 AM
Unknown Object (File)
Oct 21 2024, 4:44 AM
Unknown Object (File)
Oct 21 2024, 4:43 AM
Unknown Object (File)
Oct 21 2024, 4:43 AM
Unknown Object (File)
Oct 21 2024, 4:21 AM
Unknown Object (File)
Sep 24 2024, 4:48 PM
Unknown Object (File)
Sep 20 2024, 7:09 AM
Unknown Object (File)
Sep 18 2024, 3:17 PM
Subscribers

Details

Summary

RB_INSERT_COLOR has a variable, child, that is not initialized, and Coverity believes that it may be used before a value is assigned to it. It's not possible. Assigning 'NULL' as an initial value would silence coverity, but if coverity was right about the need to initialize, then it would lead to a null pointer dereference. But coverity is wrong.

So, add comments to suppress the uninit_use warnings that coverity is generating for the use of 'child' in RB_INSERT_COLOR.

Test Plan

I have no way to test this.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

dougm requested review of this revision.Jun 30 2022, 7:57 AM
dougm created this revision.

This looks like it ought to work, but I don't have any experience with these kinds of annotations.

I note that scan-build (LLVM's static analyzer) reports the same "problem." It might be useful to include a brief comment explaining why child is always initialized before use.

This revision is now accepted and ready to land.Jun 30 2022, 2:07 PM

Add a 'brief' comment.

I don't seem to have any 'scan-build' executable to test this with.

This revision now requires review to proceed.Jun 30 2022, 4:41 PM

Add a 'brief' comment.

I don't seem to have any 'scan-build' executable to test this with.

I believe it doesn't get built with the FreeBSD base system by default, one has to specify WITH_CLANG_EXTRAS. Alternately, pkg install llvm will install it to /usr/local/bin. Here's some example output: https://reviews.freebsd.org/P543

This revision is now accepted and ready to land.Jun 30 2022, 5:01 PM
This revision was automatically updated to reflect the committed changes.