Diagnosed by gcc -Wint-in-bool-context.
Details
% kyua test -k /usr/tests/sys/Kyuafile sys/bitstring_test
Diff Detail
- Repository
- rG FreeBSD src repository
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
Apologies, trying to recall. IIRC...
GCC complained because the 2nd arg to the ternary is bool and the 3rd is int. Here it mean that the behavior for j + 1 == nbits wasn't being tested, but we should test that the result is -1.
(j + 1 < nbits) ? found_set_bit == j + 1 : -1, ^^^^^^^^^^^^^^^^^^^^^^ ^^ | | true or false, depending on result | | always true---------------------------------|
So is -1 being cast to true? Thank you GCC for telling us that. If so, I think we should replace ATF_REQUIRE_MSG with ATF_REQUIRE_EQ_MSG. I think that would be more clear.
Effectively, yes.
Thank you GCC for telling us that. If so, I think we should replace ATF_REQUIRE_MSG with ATF_REQUIRE_EQ_MSG. I think that would be more clear.
Sure, I'll work that up.
asomers feedback: use ATF_REQUIRE_EQ family of tests.
I converted the nearby tests to ATF_REQUIRE_INTEQ_MSG, but I left the 40
other instances in this file alone.
I selected INTEQ instead of EQ as that variant outputs the actual
values on failure.