Page MenuHomeFreeBSD

rb_tree: silence coverity
ClosedPublic

Authored by dougm on Jun 30 2022, 7:57 AM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 11 2024, 12:35 AM
Unknown Object (File)
Jan 14 2024, 6:16 AM
Unknown Object (File)
Dec 29 2023, 10:43 AM
Unknown Object (File)
Dec 22 2023, 11:28 PM
Unknown Object (File)
Dec 10 2023, 12:55 AM
Unknown Object (File)
Oct 10 2023, 12:26 PM
Unknown Object (File)
Oct 1 2023, 2:07 PM
Unknown Object (File)
Aug 17 2023, 6:48 AM
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.