Fix more static analysis warnings

master
Xavier Arteaga 4 years ago committed by Xavier Arteaga
parent 70d6e4d9b3
commit b6fa82bf9a

@ -314,7 +314,7 @@ int main(int argc, char** argv)
// SCI
srsran_sci_t sci;
srsran_sci_init(&sci, cell_sl, sl_comm_resource_pool);
srsran_sci_init(&sci, &cell_sl, &sl_comm_resource_pool);
uint8_t sci_rx[SRSRAN_SCI_MAX_LEN] = {};
char sci_msg[SRSRAN_SCI_MSG_MAX_LEN] = {};
@ -337,7 +337,7 @@ int main(int argc, char** argv)
return SRSRAN_ERROR;
}
if (srsran_pssch_init(&pssch, cell_sl, sl_comm_resource_pool) != SRSRAN_SUCCESS) {
if (srsran_pssch_init(&pssch, &cell_sl, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH");
return SRSRAN_ERROR;
}

@ -106,8 +106,9 @@ typedef struct SRSRAN_API {
} srsran_pssch_t;
SRSRAN_API int
srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool);
SRSRAN_API int srsran_pssch_init(srsran_pssch_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool);
SRSRAN_API int srsran_pssch_set_cfg(srsran_pssch_t* q, srsran_pssch_cfg_t pssch_cfg);
SRSRAN_API int srsran_pssch_encode(srsran_pssch_t* q, uint8_t* input, uint32_t input_len, cf_t* sf_buffer);
SRSRAN_API int srsran_pssch_decode(srsran_pssch_t* q, cf_t* equalized_sf_syms, uint8_t* output, uint32_t output_len);

@ -89,8 +89,9 @@ typedef struct SRSRAN_API {
} srsran_sci_t;
SRSRAN_API int
srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool);
SRSRAN_API int srsran_sci_init(srsran_sci_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool);
SRSRAN_API int srsran_sci_format0_pack(srsran_sci_t* q, uint8_t* output);
SRSRAN_API int srsran_sci_format1_pack(srsran_sci_t* q, uint8_t* output);
SRSRAN_API int srsran_sci_format0_unpack(srsran_sci_t* q, uint8_t* input);

@ -81,6 +81,7 @@ int main(int argc, char** argv)
uint8_t * input, *input_bytes, *output;
cf_t * symbols, *symbols_bytes;
float* llr;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv);
@ -133,14 +134,14 @@ int main(int argc, char** argv)
/* generate random data */
for (i = 0; i < num_bits; i++) {
input[i] = rand() % 2;
input[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
}
/* modulate */
struct timeval t[3];
gettimeofday(&t[1], NULL);
int ntrials = 100;
for (int i = 0; i < ntrials; i++) {
for (int j = 0; j < ntrials; j++) {
srsran_mod_modulate(&mod, input, symbols, num_bits);
}
gettimeofday(&t[2], NULL);
@ -151,16 +152,16 @@ int main(int argc, char** argv)
/* Test packed implementation */
srsran_bit_pack_vector(input, input_bytes, num_bits);
gettimeofday(&t[1], NULL);
for (int i = 0; i < ntrials; i++) {
for (int j = 0; j < ntrials; j++) {
srsran_mod_modulate_bytes(&mod, input_bytes, symbols_bytes, num_bits);
}
gettimeofday(&t[2], NULL);
get_time_interval(t);
printf("Byte: %ld us\n", t[0].tv_usec);
for (int i = 0; i < num_bits / mod.nbits_x_symbol; i++) {
if (symbols[i] != symbols_bytes[i]) {
printf("error in symbol %d\n", i);
for (int j = 0; i < num_bits / mod.nbits_x_symbol; j++) {
if (symbols[j] != symbols_bytes[j]) {
printf("error in symbol %d\n", j);
exit(-1);
}
}
@ -191,7 +192,7 @@ int main(int argc, char** argv)
free(output);
free(input);
free(input_bytes);
srsran_random_free(random_gen);
srsran_modem_table_free(&mod);
exit(ret);

@ -21,23 +21,25 @@
#include "srsran/phy/utils/debug.h"
#include "srsran/phy/utils/vector.h"
int srsran_pssch_init(srsran_pssch_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool)
int srsran_pssch_init(srsran_pssch_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool)
{
if (q == NULL) {
if (q == NULL || cell == NULL || sl_comm_resource_pool == NULL) {
return SRSRAN_ERROR_INVALID_INPUTS;
}
q->cell = cell;
q->sl_comm_resource_pool = sl_comm_resource_pool;
q->cell = *cell;
q->sl_comm_resource_pool = *sl_comm_resource_pool;
if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) {
if (cell.cp == SRSRAN_CP_NORM) {
if (cell->tm == SRSRAN_SIDELINK_TM1 || cell->tm == SRSRAN_SIDELINK_TM2) {
if (cell->cp == SRSRAN_CP_NORM) {
q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS;
} else {
q->nof_data_symbols = SRSRAN_PSSCH_TM12_NUM_DATA_SYMBOLS_CP_EXT;
}
} else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) {
if (cell.cp == SRSRAN_CP_NORM) {
} else if (cell->tm == SRSRAN_SIDELINK_TM3 || cell->tm == SRSRAN_SIDELINK_TM4) {
if (cell->cp == SRSRAN_CP_NORM) {
q->nof_data_symbols = SRSRAN_PSSCH_TM34_NUM_DATA_SYMBOLS;
} else {
ERROR("Invalid CP for PSSCH, SL TM 3/4");

@ -162,9 +162,9 @@ static ra_nr_table_t ra_nr_select_table_pusch_noprecoding(srsran_mcs_table_t
// - the UE is configured with MCS-C-RNTI, and
// - the PUSCH is scheduled by a PDCCH with
// - CRC scrambled by MCS-C-RNTI,
if (mcs_c_rnti && dci_format != srsran_dci_format_nr_rar && rnti_type == srsran_rnti_type_mcs_c) {
return ra_nr_table_3;
}
// if (mcs_c_rnti && dci_format != srsran_dci_format_nr_rar && rnti_type == srsran_rnti_type_mcs_c) {
// return ra_nr_table_3;
// }
// - mcs-Table in configuredGrantConfig is set to 'qam256',
// - if PUSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or
@ -192,7 +192,6 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srsran_mcs_table_t mcs_tab
{
// Non-implemented parameters
bool sps_config_mcs_table_present = false;
srsran_mcs_table_t sps_config_mcs_table = srsran_mcs_table_64qam;
bool is_pdcch_sps = false;
// - the higher layer parameter mcs-Table given by PDSCH-Config is set to 'qam256', and
@ -224,10 +223,10 @@ static ra_nr_table_t ra_nr_select_table_pdsch(srsran_mcs_table_t mcs_tab
// - the UE is configured with the higher layer parameter mcs-Table given by SPS-Config set to 'qam64LowSE'
// - if the PDSCH is scheduled by a PDCCH with CRC scrambled by CS-RNTI or
// - if the PDSCH is scheduled without corresponding PDCCH transmission using SPS-Config,
if (sps_config_mcs_table_present && sps_config_mcs_table == srsran_mcs_table_qam64LowSE &&
(rnti_type == srsran_rnti_type_cs || is_pdcch_sps)) {
return ra_nr_table_3;
}
// if (sps_config_mcs_table_present && sps_config_mcs_table == srsran_mcs_table_qam64LowSE &&
// (rnti_type == srsran_rnti_type_cs || is_pdcch_sps)) {
// return ra_nr_table_3;
// }
// else
return ra_nr_table_1;

@ -15,7 +15,9 @@
#include "srsran/phy/phch/sci.h"
#include "srsran/phy/utils/bit.h"
int srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resource_pool_t sl_comm_resource_pool)
int srsran_sci_init(srsran_sci_t* q,
const srsran_cell_sl_t* cell,
const srsran_sl_comm_resource_pool_t* sl_comm_resource_pool)
{
int ret = SRSRAN_ERROR_INVALID_INPUTS;
if (q != NULL) {
@ -23,18 +25,18 @@ int srsran_sci_init(srsran_sci_t* q, srsran_cell_sl_t cell, srsran_sl_comm_resou
bzero(q, sizeof(srsran_sci_t));
q->nof_prb = cell.nof_prb;
q->tm = cell.tm;
q->nof_prb = cell->nof_prb;
q->tm = cell->tm;
if (cell.tm == SRSRAN_SIDELINK_TM1 || cell.tm == SRSRAN_SIDELINK_TM2) {
if (cell->tm == SRSRAN_SIDELINK_TM1 || cell->tm == SRSRAN_SIDELINK_TM2) {
q->format = SRSRAN_SCI_FORMAT0;
q->sci_len = srsran_sci_format0_sizeof(cell.nof_prb);
q->sci_len = srsran_sci_format0_sizeof(cell->nof_prb);
} else if (cell.tm == SRSRAN_SIDELINK_TM3 || cell.tm == SRSRAN_SIDELINK_TM4) {
} else if (cell->tm == SRSRAN_SIDELINK_TM3 || cell->tm == SRSRAN_SIDELINK_TM4) {
q->format = SRSRAN_SCI_FORMAT1;
q->sci_len = SRSRAN_SCI_TM34_LEN;
q->size_sub_channel = sl_comm_resource_pool.size_sub_channel;
q->num_sub_channel = sl_comm_resource_pool.num_sub_channel;
q->size_sub_channel = sl_comm_resource_pool->size_sub_channel;
q->num_sub_channel = sl_comm_resource_pool->num_sub_channel;
} else {
return SRSRAN_ERROR;

@ -48,6 +48,8 @@ uint16_t rnti = 1234;
uint16_t i_tbs_val = 0;
char* input_file = NULL;
static srsran_random_t random_gen = NULL;
void usage(char* prog)
{
printf("Usage: %s [fmMlsrRFpnv] \n", prog);
@ -163,7 +165,7 @@ int get_ref_res(srsran_nbiot_cell_t cell, int32_t* re_with_refs)
return num_ref;
}
int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re)
int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof_re2)
{
srsran_npdsch_t npdsch;
bzero(&npdsch, sizeof(srsran_npdsch_t));
@ -197,8 +199,8 @@ int extract_re(srsran_nbiot_cell_t cell, uint32_t l_start, uint32_t expected_nof
#endif
// check number of extracted REs
if (nof_ext_syms != expected_nof_re) {
printf("RE extraction failed (expected %d, but got %d)!\n", expected_nof_re, nof_ext_syms);
if (nof_ext_syms != expected_nof_re2) {
printf("RE extraction failed (expected %d, but got %d)!\n", expected_nof_re2, nof_ext_syms);
return SRSRAN_ERROR;
}
@ -234,7 +236,9 @@ int re_extract_test(int argc, char** argv)
// Standalone mode with l_start=0 gives the maximum number of REs
cell.mode = mode;
cell.base.nof_prb = 1;
cell.base.id = (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI) ? n_id_ncell : rand() % SRSRAN_NUM_PCI;
cell.base.id = (mode == SRSRAN_NBIOT_MODE_INBAND_SAME_PCI)
? n_id_ncell
: srsran_random_uniform_int_dist(random_gen, 0, SRSRAN_NUM_PCI - 1);
cell.n_id_ncell = n_id_ncell;
cell.nof_ports = nof_ports_nbiot;
cell.base.nof_ports = nof_ports_lte;
@ -379,9 +383,8 @@ int coding_test(int argc, char** argv)
}
// generate random data
srand(time(NULL));
for (int i = 0; i < grant.mcs[0].tbs / 8; i++) {
data[i] = rand() % 256;
data[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 255);
}
if (!input_file) {
@ -463,8 +466,8 @@ quit:
int main(int argc, char** argv)
{
int ret = SRSRAN_ERROR;
int ret = SRSRAN_ERROR;
random_gen = srsran_random_init(0x1234);
if (re_extract_test(argc, argv) != SRSRAN_SUCCESS) {
printf("Resource element extraction test failed!\n");
return ret;

@ -72,6 +72,7 @@ int main(int argc, char** argv)
int nof_re;
cf_t* sf_symbols[SRSRAN_MAX_PORTS];
uint32_t nof_rx_ports;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv);
@ -100,9 +101,8 @@ int main(int argc, char** argv)
exit(-1);
}
srand(time(NULL));
for (i = 0; i < SRSRAN_BCH_PAYLOAD_LEN; i++) {
bch_payload_tx[i] = rand() % 2;
bch_payload_tx[i] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
}
srsran_pbch_encode(&pbch, bch_payload_tx, sf_symbols, 0);
@ -127,6 +127,7 @@ int main(int argc, char** argv)
}
srsran_chest_dl_res_free(&chest_dl_res);
srsran_random_free(random_gen);
printf("Tx ports: %d - Rx ports: %d\n", cell.nof_ports, nof_rx_ports);
printf("Tx payload: ");

@ -164,6 +164,7 @@ int main(int argc, char** argv)
int nof_dcis;
bzero(&testcases, sizeof(testcase_dci_t) * 10);
srsran_random_t random_gen = srsran_random_init(0x1234);
int ret = -1;
@ -224,14 +225,14 @@ int main(int argc, char** argv)
dci.type0_alloc.rbg_bitmask = 0x5;
dci.cif_present = dci_cfg.cif_enabled;
if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7);
dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
}
/* Format 1 Test case */
if (cell.nof_ports == 1) {
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1;
if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7);
dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
}
testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++;
@ -240,7 +241,7 @@ int main(int argc, char** argv)
dci.tb[0].mcs_idx = 15;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT1;
if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7);
dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
}
testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++;
@ -253,7 +254,7 @@ int main(int argc, char** argv)
dci.tb[1].ndi = true;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2A;
if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7);
dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
}
testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++;
@ -266,15 +267,12 @@ int main(int argc, char** argv)
dci.tb[1].ndi = false;
testcases[nof_dcis].dci_format = SRSRAN_DCI_FORMAT2;
if (dci_cfg.cif_enabled) {
dci.cif = (uint32_t)(random() & 0x7);
dci.cif = (uint32_t)srsran_random_uniform_int_dist(random_gen, 0, 7);
}
testcases[nof_dcis].ra_dl_tx = dci;
nof_dcis++;
}
srsran_dci_cfg_t dci_cfg;
ZERO_OBJECT(dci_cfg);
srsran_dl_sf_cfg_t dl_sf;
ZERO_OBJECT(dl_sf);
dl_sf.cfi = cfi;
@ -391,6 +389,7 @@ quit:
srsran_pdcch_free(&pdcch_rx);
srsran_chest_dl_res_free(&chest_dl_res);
srsran_regs_free(&regs);
srsran_random_free(random_gen);
for (i = 0; i < SRSRAN_MAX_PORTS; i++) {
free(slot_symbols[i]);

@ -194,6 +194,7 @@ int main(int argc, char** argv)
srsran_chest_dl_t chest;
srsran_chest_dl_res_t chest_res;
srsran_pdsch_res_t pdsch_res[SRSRAN_MAX_CODEWORDS];
srsran_random_t random_gen = srsran_random_init(0x1234);
/* Initialise to zeros */
ZERO_OBJECT(softbuffers_tx);
@ -386,7 +387,7 @@ int main(int argc, char** argv)
for (int tb = 0; tb < SRSRAN_MAX_CODEWORDS; tb++) {
if (pdsch_cfg.grant.tb[tb].enabled) {
for (int byte = 0; byte < pdsch_cfg.grant.tb[tb].tbs / 8; byte++) {
data_tx[tb][byte] = (uint8_t)(rand() % 256);
data_tx[tb][byte] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 255);
}
}
}
@ -566,6 +567,7 @@ quit:
free(rx_slot_symbols[i]);
}
}
srsran_random_free(random_gen);
if (ret) {
printf("Error\n");
} else {

@ -89,15 +89,16 @@ void parse_args(int argc, char** argv)
int main(int argc, char** argv)
{
srsran_phich_t phich;
srsran_regs_t regs;
int i, j;
int nof_re;
cf_t* slot_symbols[SRSRAN_MAX_PORTS];
uint8_t ack[50][SRSRAN_PHICH_NORM_NSEQUENCES];
uint32_t nsf;
int cid, max_cid;
uint32_t ngroup, nseq, max_nseq;
srsran_phich_t phich;
srsran_regs_t regs;
int i, j;
int nof_re;
cf_t* slot_symbols[SRSRAN_MAX_PORTS];
uint8_t ack[50][SRSRAN_PHICH_NORM_NSEQUENCES];
uint32_t nsf;
int cid, max_cid;
uint32_t ngroup, nseq, max_nseq;
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv);
@ -161,7 +162,7 @@ int main(int argc, char** argv)
resource.ngroup = ngroup;
resource.nseq = nseq;
ack[ngroup][nseq] = rand() % 2;
ack[ngroup][nseq] = (uint8_t)srsran_random_uniform_int_dist(random_gen, 0, 1);
srsran_phich_encode(&phich, &dl_sf, resource, ack[ngroup][nseq], slot_symbols);
}
@ -207,7 +208,7 @@ int main(int argc, char** argv)
cid++;
}
srsran_phich_free(&phich);
srsran_random_free(random_gen);
srsran_chest_dl_res_free(&chest_res);
for (i = 0; i < SRSRAN_MAX_PORTS; i++) {

@ -143,11 +143,10 @@ void stagger_prach_powers(srsran_prach_t* prach,
int main(int argc, char** argv)
{
parse_args(argc, argv);
srsran_prach_t prach;
bool high_speed_flag = false;
srand(0);
cf_t preamble[MAX_LEN];
srsran_prach_t prach;
srsran_random_t random_gen = srsran_random_init(0x1234);
bool high_speed_flag = false;
cf_t preamble[MAX_LEN];
memset(preamble, 0, sizeof(cf_t) * MAX_LEN);
cf_t preamble_sum[MAX_LEN];
memset(preamble_sum, 0, sizeof(cf_t) * MAX_LEN);
@ -182,7 +181,7 @@ int main(int argc, char** argv)
printf("limiting number of preambles to 6\n");
if (test_offset_calculation) {
for (int i = 0; i < 6; i++) {
offsets[i] = (rand() % 50);
offsets[i] = srsran_random_uniform_int_dist(random_gen, 0, 49);
}
}
}
@ -252,6 +251,7 @@ int main(int argc, char** argv)
}
srsran_prach_free(&prach);
srsran_random_free(random_gen);
printf("Done\n");
exit(0);
}

@ -98,7 +98,7 @@ int main(int argc, char** argv)
// SCI
srsran_sci_t sci;
srsran_sci_init(&sci, cell, sl_comm_resource_pool);
srsran_sci_init(&sci, &cell, &sl_comm_resource_pool);
sci.mcs_idx = 2;
// PSCCH

@ -151,7 +151,10 @@ int base_init()
}
srsran_vec_cf_zero(input_buffer, sf_n_samples);
srsran_sci_init(&sci, cell, sl_comm_resource_pool);
if (srsran_sci_init(&sci, &cell, &sl_comm_resource_pool) < SRSRAN_SUCCESS) {
ERROR("Error in SCI init");
return SRSRAN_ERROR;
}
if (srsran_pscch_init(&pscch, SRSRAN_MAX_PRB) != SRSRAN_SUCCESS) {
ERROR("Error in PSCCH init");
@ -168,7 +171,7 @@ int base_init()
return SRSRAN_ERROR;
}
if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) {
if (srsran_pssch_init(&pssch, &cell, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH");
return SRSRAN_ERROR;
}

@ -83,7 +83,7 @@ int main(int argc, char** argv)
}
srsran_pssch_t pssch = {};
if (srsran_pssch_init(&pssch, cell, sl_comm_resource_pool) != SRSRAN_SUCCESS) {
if (srsran_pssch_init(&pssch, &cell, &sl_comm_resource_pool) != SRSRAN_SUCCESS) {
ERROR("Error initializing PSSCH");
return SRSRAN_ERROR;
}

@ -10,6 +10,7 @@
*
*/
#include "srsran/phy/utils/random.h"
#include <complex.h>
#include <math.h>
#include <stdio.h>
@ -22,10 +23,10 @@
#include "srsran/phy/utils/vector.h"
uint32_t N = 256;
bool forward = true;
bool mirror = false;
bool norm = false;
bool dc = false;
bool forward = true;
bool mirror = false;
bool norm = false;
bool dc = false;
void usage(char* prog)
{
@ -132,19 +133,17 @@ int test_dft(cf_t* in)
int main(int argc, char** argv)
{
srsran_random_t random_gen = srsran_random_init(0x1234);
parse_args(argc, argv);
cf_t* in = srsran_vec_cf_malloc(N);
srsran_vec_cf_zero(in, N);
for (int i = 1; i < N - 1; i++) {
float re = 100 * rand() / (float)RAND_MAX;
float im = 100 * rand() / (float)RAND_MAX;
in[i] = re + im * I;
}
in[0] = 0.0f;
srsran_random_uniform_complex_dist_vector(random_gen, &in[1], N - 1, -1, 1);
if (test_dft(in) != 0)
return -1;
free(in);
srsran_random_free(random_gen);
printf("Done\n");
exit(0);
}

Loading…
Cancel
Save