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
This commit is contained in:
Vadim Yanitskiy 2023-12-08 03:58:36 +07:00
parent c58e4851f4
commit 74b31acb5d
1 changed files with 2 additions and 2 deletions

View File

@ -441,11 +441,11 @@ static void test_pdtch(const struct test_macblock *tmb, int len)
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;
}