fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/35259?usp=email )
Change subject: tests/coding: fix -Wmaybe-uninitialized in test_pdtch() ......................................................................
tests/coding: fix -Wmaybe-uninitialized in test_pdtch()
I am seeing this when building with gcc v13.2.1:
tests/coding/coding_test.c: In function ‘test_pdtch’: tests/coding/coding_test.c:444:23: warning: ‘*result[<unknown>]’ may be used uninitialized 444 | result[len - 1] &= 0x7f; | ~~~~~~^~~~~~~~~ tests/coding/coding_test.c:448:23: warning: ‘*result[39]’ may be used uninitialized 448 | result[len - 1] &= 0x07; | ~~~~~~^~~~~~~~~
The idea here is to pre-clear some bits in the resulting buffer, because they're not going to be set during decoding of the burst bits. The problem is that result[] holds uninitialized data, so we're basically taking a 'garbage' octet and clear some of its bits. The remaining 'garbage' bits of that octet are overwritten by the decoder, so in the end we still get deterministic results.
Let's make GCC happy by clearing all bits in the last octet.
Change-Id: I24d79de8b3a5f4184b71414504657e5857498e0e --- M tests/coding/coding_test.c 1 file changed, 32 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/59/35259/1
diff --git a/tests/coding/coding_test.c b/tests/coding/coding_test.c index c9508f7..d536e44 100644 --- a/tests/coding/coding_test.c +++ b/tests/coding/coding_test.c @@ -441,11 +441,11 @@ case 34: case 54: l2[len - 1] &= 0x7f; - result[len - 1] &= 0x7f; + result[len - 1] = 0x00; break; case 40: l2[len - 1] &= 0x07; - result[len - 1] &= 0x07; + result[len - 1] = 0x00; break; }