tests/v110: assert(user_data_chunk_bits) in test_ra1()

Coverity warns that osmo_v110_sync_ra1_get_user_data_chunk_bitlen() may
return a negative value, which is used as loop boundary.  Even though
this is unlikely, let's add an assert().

Change-Id: I0fc0e0bac74bd96351030432ef1b140b727acb0d
Fixes: CID#310968
This commit is contained in:
Vadim Yanitskiy 2023-03-17 16:35:51 +07:00
parent 0a60e422a8
commit 8f6d2f349c
1 changed files with 4 additions and 1 deletions

View File

@ -10,7 +10,7 @@
static void test_ra1(enum osmo_v100_sync_ra1_rate rate)
{
int user_rate = osmo_v110_sync_ra1_get_user_data_rate(rate);
int user_data_chunk_bits = osmo_v110_sync_ra1_get_user_data_chunk_bitlen(rate);
int user_data_chunk_bits;
struct osmo_v110_decoded_frame fr;
ubit_t user_bits[48];
ubit_t bits[80];
@ -19,6 +19,9 @@ static void test_ra1(enum osmo_v100_sync_ra1_rate rate)
printf("\n======= User data rate %u\n", user_rate);
user_data_chunk_bits = osmo_v110_sync_ra1_get_user_data_chunk_bitlen(rate);
OSMO_ASSERT(user_data_chunk_bits >= 0);
/* we abuse the fact that ubit_t is 8bit so we can actually
* store integer values to clearly identify which bit ends up where */
memset(user_bits, 0xFE, sizeof(user_bits));