Fixes coverity 370816

This commit is contained in:
Alejandro Leal Conejos 2021-10-27 11:47:40 +02:00 committed by Ismael Gomez
parent 0fdbfcffd0
commit 6cd917fca5
1 changed files with 10 additions and 2 deletions

View File

@ -182,8 +182,16 @@ private:
/// TS 36.321, Table 7.2.2-2
static uint32_t nof_bandwidth_parts(uint32_t nof_prb)
{
static const uint32_t nrb[] = {0, 2, 2, 3, 4, 4};
return nrb[srsran::lte_cell_nof_prb_to_index(nof_prb)];
static const uint32_t nrb_size = 6u;
static const uint32_t nrb[] = {0, 2, 2, 3, 4, 4};
uint32_t index = srsran::lte_cell_nof_prb_to_index(nof_prb);
srsran_assert(index < nrb_size, "nrb index out of bounds");
// Fix error out of bounds, returns the array's first element by default.
index = (index < nrb_size) ? index : 0;
return nrb[index];
}
uint32_t J() const { return nof_bandwidth_parts(); }