Updated array index check with macro def in log.h
This commit is contained in:
@@ -54,6 +54,12 @@
|
|||||||
#include "T.h"
|
#include "T.h"
|
||||||
#include <common/utils/utils.h>
|
#include <common/utils/utils.h>
|
||||||
/*----------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------*/
|
||||||
|
#include <assert.h>
|
||||||
|
#ifdef NDEBUG
|
||||||
|
#warning assert is disabled
|
||||||
|
#endif
|
||||||
|
#define NUM_ELEMENTS(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
|
||||||
|
#define CHECK_INDEX(ARRAY, INDEX) assert((INDEX) < NUM_ELEMENTS(ARRAY))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|||||||
@@ -1949,9 +1949,10 @@ char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int pdu_size = sf_rnti_mcs[sf].pdu_size;
|
int pdu_size = sf_rnti_mcs[sf].pdu_size;
|
||||||
|
CHECK_INDEX(sf_rnti_mcs[sf].rnti, pdu_size);
|
||||||
|
CHECK_INDEX(sf_rnti_mcs[sf].drop_flag, pdu_size);
|
||||||
for (int n = 0; n < pdu_size; n++)
|
for (int n = 0; n < pdu_size; n++)
|
||||||
{
|
{
|
||||||
assert(n < sizeof(sf_rnti_mcs[sf].drop_flag));
|
|
||||||
if (sf_rnti_mcs[sf].rnti[n] == rnti)
|
if (sf_rnti_mcs[sf].rnti[n] == rnti)
|
||||||
{
|
{
|
||||||
return sf_rnti_mcs[sf].drop_flag[n];
|
return sf_rnti_mcs[sf].drop_flag[n];
|
||||||
@@ -1973,9 +1974,11 @@ char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req)
|
|||||||
uint8_t mcs = 99;
|
uint8_t mcs = 99;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int pdu_size = sf_rnti_mcs[sf].pdu_size;
|
int pdu_size = sf_rnti_mcs[sf].pdu_size;
|
||||||
|
CHECK_INDEX(sf_rnti_mcs[sf].rnti, pdu_size);
|
||||||
|
CHECK_INDEX(sf_rnti_mcs[sf].mcs, pdu_size);
|
||||||
|
CHECK_INDEX(sf_rnti_mcs[sf].drop_flag, pdu_size);
|
||||||
for (n = 0; n < pdu_size; n++)
|
for (n = 0; n < pdu_size; n++)
|
||||||
{
|
{
|
||||||
assert(n < sizeof(sf_rnti_mcs[sf].drop_flag) && n < sizeof(sf_rnti_mcs[sf].mcs) && n < sizeof(sf_rnti_mcs[sf].rnti));
|
|
||||||
if (sf_rnti_mcs[sf].rnti[n] == rnti)
|
if (sf_rnti_mcs[sf].rnti[n] == rnti)
|
||||||
{
|
{
|
||||||
mcs = sf_rnti_mcs[sf].mcs[n];
|
mcs = sf_rnti_mcs[sf].mcs[n];
|
||||||
@@ -2049,7 +2052,7 @@ char *nfapi_ul_config_req_to_string(nfapi_ul_config_request_t *req)
|
|||||||
|
|
||||||
double drop_cutoff = ((double) rand() / (RAND_MAX));
|
double drop_cutoff = ((double) rand() / (RAND_MAX));
|
||||||
assert(drop_cutoff < 1);
|
assert(drop_cutoff < 1);
|
||||||
bler_val = 0.6;
|
bler_val = 0.4;
|
||||||
|
|
||||||
if (bler_val >= drop_cutoff)
|
if (bler_val >= drop_cutoff)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user