Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Coverity-only code to assert (CID #1619299) #5441

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/lib/util/nbo.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,12 @@ static inline size_t fr_nbo_from_uint64v(uint8_t out[static sizeof(uint64_t)], u
ret = ROUND_UP_DIV((size_t)fr_high_bit_pos(num | 0x80), 8);
#ifdef __COVERITY__
/*
* Coverity doesn't realize that ret is necessarily <= 8,
* so we give it a hint.
* Coverity doesn't realize that the fr_high_bit_pos() call will always
* return a value between 1 and 8 inclusive, the former thanks to the
* "| 0x80". and this function doesn't specify an error return value,
* so we use a Coverity-only assert.
*/
if (ret > 8) return 0;
fr_assert(ret >= 1 && ret <= 8);
#endif

fr_nbo_from_uint64(swapped, num);
Expand Down
Loading