diff --git a/lib/examples/cell_search.c b/lib/examples/cell_search.c index 4156a076e..7565c8736 100644 --- a/lib/examples/cell_search.c +++ b/lib/examples/cell_search.c @@ -86,19 +86,19 @@ void parse_args(int argc, char **argv) { rf_args = argv[optind]; break; case 'b': - band = atoi(argv[optind]); + band = (int)strtol(argv[optind], NULL, 10); break; case 's': - earfcn_start = atoi(argv[optind]); + earfcn_start = (int)strtol(argv[optind], NULL, 10); break; case 'e': - earfcn_end = atoi(argv[optind]); + earfcn_end = (int)strtol(argv[optind], NULL, 10); break; case 'n': - cell_detect_config.max_frames_pss = atoi(argv[optind]); + cell_detect_config.max_frames_pss = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'v': srslte_verbose++; diff --git a/lib/examples/pdsch_enodeb.c b/lib/examples/pdsch_enodeb.c index 053a3db3d..7445ac8b8 100644 --- a/lib/examples/pdsch_enodeb.c +++ b/lib/examples/pdsch_enodeb.c @@ -163,52 +163,52 @@ void parse_args(int argc, char **argv) { rf_args = argv[optind]; break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'l': - rf_amp = atof(argv[optind]); + rf_amp = strtof(argv[optind], NULL); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 'o': output_file_name = argv[optind]; break; case 'm': - mcs_idx = atoi(argv[optind]); + mcs_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'u': - net_port = atoi(argv[optind]); + net_port = (int)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'x': - transmission_mode = (srslte_tm_t)(atoi(argv[optind]) - 1); + transmission_mode = (srslte_tm_t)(strtol(argv[optind], NULL, 10) - 1); break; case 'b': - multiplex_pmi = (uint32_t) atoi(argv[optind]); + multiplex_pmi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'w': - multiplex_nof_layers = (uint32_t) atoi(argv[optind]); + multiplex_nof_layers = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'M': - mbsfn_area_id = atoi(argv[optind]); + mbsfn_area_id = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; break; case 's': - output_file_snr = atof(argv[optind]); + output_file_snr = strtof(argv[optind], NULL); break; case 'B': - mbsfn_sf_mask = atoi(argv[optind]); + mbsfn_sf_mask = (uint8_t)strtol(argv[optind], NULL, 10); break; case 'q': enable_256qam ^= true; @@ -627,7 +627,7 @@ int update_control() { break; default: last_mcs_idx = mcs_idx; - mcs_idx = atoi(input); + mcs_idx = strtol(input, NULL, 10); } } bzero(input,sizeof(input)); diff --git a/lib/examples/pdsch_ue.c b/lib/examples/pdsch_ue.c index 973970616..33af4f8b2 100644 --- a/lib/examples/pdsch_ue.c +++ b/lib/examples/pdsch_ue.c @@ -208,19 +208,19 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->input_file_name = argv[optind]; break; case 'p': - args->file_nof_prb = atoi(argv[optind]); + args->file_nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'P': - args->file_nof_ports = atoi(argv[optind]); + args->file_nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - args->file_offset_freq = atof(argv[optind]); + args->file_offset_freq = strtof(argv[optind], NULL); break; case 'O': - args->file_offset_time = atoi(argv[optind]); + args->file_offset_time = (int)strtol(argv[optind], NULL, 10); break; case 'c': - args->file_cell_id = atoi(argv[optind]); + args->file_cell_id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'I': args->rf_dev = argv[optind]; @@ -229,10 +229,10 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->rf_args = argv[optind]; break; case 'A': - args->rf_nof_rx_ant = atoi(argv[optind]); + args->rf_nof_rx_ant = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'g': - args->rf_gain = atof(argv[optind]); + args->rf_gain = strtof(argv[optind], NULL); break; case 'C': args->disable_cfo = true; @@ -244,34 +244,34 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->average_subframe = true; break; case 't': - args->time_offset = atoi(argv[optind]); + args->time_offset = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'f': args->rf_freq = strtod(argv[optind], NULL); break; case 'T': - args->tdd_special_sf = atoi(argv[optind]); + args->tdd_special_sf = (int)strtol(argv[optind], NULL, 10); break; case 'G': - args->sf_config = atoi(argv[optind]); + args->sf_config = (int)strtol(argv[optind], NULL, 10); break; case 'n': - args->nof_subframes = atoi(argv[optind]); + args->nof_subframes = (int)strtol(argv[optind], NULL, 10); break; case 'r': args->rnti = strtol(argv[optind], NULL, 16); break; case 'l': - args->force_N_id_2 = atoi(argv[optind]); + args->force_N_id_2 = (int)strtol(argv[optind], NULL, 10); break; case 'u': - args->net_port = atoi(argv[optind]); + args->net_port = (int)strtol(argv[optind], NULL, 10); break; case 'U': args->net_address = argv[optind]; break; case 's': - args->net_port_signal = atoi(argv[optind]); + args->net_port_signal = (int)strtol(argv[optind], NULL, 10); break; case 'S': args->net_address_signal = argv[optind]; @@ -287,22 +287,22 @@ void parse_args(prog_args_t *args, int argc, char **argv) { args->verbose = srslte_verbose; break; case 'Z': - args->decimate = atoi(argv[optind]); + args->decimate = (int)strtol(argv[optind], NULL, 10); break; case 'y': - args->cpu_affinity = atoi(argv[optind]); + args->cpu_affinity = (int)strtol(argv[optind], NULL, 10); break; case 'W': output_file_name = argv[optind]; break; case 'M': - args->mbsfn_area_id = atoi(argv[optind]); + args->mbsfn_area_id = (int32_t)strtol(argv[optind], NULL, 10); break; case 'N': - args->non_mbsfn_region = atoi(argv[optind]); + args->non_mbsfn_region = (uint8_t)strtol(argv[optind], NULL, 10); break; case 'B': - args->mbsfn_sf_mask = atoi(argv[optind]); + args->mbsfn_sf_mask = (uint8_t)strtol(argv[optind], NULL, 10); break; case 'q': args->enable_256qam ^= true; diff --git a/lib/examples/synch_file.c b/lib/examples/synch_file.c index 204b8ff27..71fd6a273 100644 --- a/lib/examples/synch_file.c +++ b/lib/examples/synch_file.c @@ -60,25 +60,25 @@ void parse_args(int argc, char **argv) { output_file_name = argv[optind]; break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'l': - frame_length = atoi(argv[optind]); + frame_length = (int)strtol(argv[optind], NULL, 10); break; case 't': - corr_peak_threshold = atof(argv[optind]); + corr_peak_threshold = strtof(argv[optind], NULL); break; case 's': - symbol_sz = atof(argv[optind]); + symbol_sz = (int)strtol(argv[optind], NULL, 10); break; case 'N': - out_N_id_2 = atoi(argv[optind]); + out_N_id_2 = (int)strtol(argv[optind], NULL, 10); break; case 'f': - force_N_id_2 = atoi(argv[optind]); + force_N_id_2 = (int)strtol(argv[optind], NULL, 10); break; case 'c': - force_cfo = atof(argv[optind]); + force_cfo = strtof(argv[optind], NULL); break; case 'v': srslte_verbose++; diff --git a/lib/examples/usrp_capture.c b/lib/examples/usrp_capture.c index 38d79fd69..919cd6c7c 100644 --- a/lib/examples/usrp_capture.c +++ b/lib/examples/usrp_capture.c @@ -66,19 +66,19 @@ void parse_args(int argc, char **argv) { rf_args = argv[optind]; break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'r': - rf_rate = atof(argv[optind]); + rf_rate = strtof(argv[optind], NULL); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 'n': - nof_samples = atoi(argv[optind]); + nof_samples = (int)strtol(argv[optind], NULL, 10); break; case 'A': - nof_rx_antennas = atoi(argv[optind]); + nof_rx_antennas = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/examples/usrp_capture_sync.c b/lib/examples/usrp_capture_sync.c index d77a99975..1aa34686a 100644 --- a/lib/examples/usrp_capture_sync.c +++ b/lib/examples/usrp_capture_sync.c @@ -67,22 +67,22 @@ void parse_args(int argc, char **argv) { rf_args = argv[optind]; break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'p': - nof_prb = atoi(argv[optind]); + nof_prb = (int)strtol(argv[optind], NULL, 10); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 'n': - nof_subframes = atoi(argv[optind]); + nof_subframes = (int)strtol(argv[optind], NULL, 10); break; case 'l': - N_id_2 = atoi(argv[optind]); + N_id_2 = (int)strtol(argv[optind], NULL, 10); break; case 'A': - nof_rx_antennas = (uint32_t) atoi(argv[optind]); + nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/examples/usrp_txrx.c b/lib/examples/usrp_txrx.c index 3f6800ac9..f47105712 100644 --- a/lib/examples/usrp_txrx.c +++ b/lib/examples/usrp_txrx.c @@ -66,22 +66,22 @@ void parse_args(int argc, char **argv) { input_filename = argv[optind]; break; case 't': - tone_offset_hz = atof(argv[optind]); + tone_offset_hz = strtof(argv[optind], NULL); break; case 'T': - time_adv_samples = atoi(argv[optind]); + time_adv_samples = (int)strtol(argv[optind], NULL, 10); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 'g': - rf_rx_gain = atof(argv[optind]); + rf_rx_gain = strtof(argv[optind], NULL); break; case 'G': - srslte_rf_tx_gain = atof(argv[optind]); + srslte_rf_tx_gain = strtof(argv[optind], NULL); break; case 'p': - nof_prb = atoi(argv[optind]); + nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); if (!srslte_nofprb_isvalid(nof_prb)) { ERROR("Invalid number of UL RB %d\n", nof_prb); exit(-1); diff --git a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c index 4154f3e74..84bfe8025 100644 --- a/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_nbiot_test_dl.c @@ -78,10 +78,10 @@ void parse_args(int argc, char** argv) while ((opt = getopt(argc, argv, "recosvnm")) != -1) { switch (opt) { case 'r': - cell.base.nof_prb = atoi(argv[optind]); + cell.base.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.n_id_ncell = atoi(argv[optind]); + cell.n_id_ncell = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': have_channel = true; @@ -90,7 +90,7 @@ void parse_args(int argc, char** argv) have_ofdm = true; break; case 's': - snr_db = (float)atof(argv[optind]); + snr_db = strtof(argv[optind], NULL); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/ch_estimation/test/chest_test_dl.c b/lib/src/phy/ch_estimation/test/chest_test_dl.c index a0d14f781..8c37e9b86 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_dl.c +++ b/lib/src/phy/ch_estimation/test/chest_test_dl.c @@ -54,13 +54,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "recov")) != -1) { switch(opt) { case 'r': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': cell.cp = SRSLTE_CP_EXT; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': output_matlab = argv[optind]; diff --git a/lib/src/phy/ch_estimation/test/chest_test_ul.c b/lib/src/phy/ch_estimation/test/chest_test_ul.c index b54305015..c57294f77 100644 --- a/lib/src/phy/ch_estimation/test/chest_test_ul.c +++ b/lib/src/phy/ch_estimation/test/chest_test_ul.c @@ -57,13 +57,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "recov")) != -1) { switch(opt) { case 'r': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': cell.cp = SRSLTE_CP_EXT; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': output_matlab = argv[optind]; diff --git a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c index ebae22c50..7d3b5de3d 100644 --- a/lib/src/phy/ch_estimation/test/refsignal_ul_test.c +++ b/lib/src/phy/ch_estimation/test/refsignal_ul_test.c @@ -55,13 +55,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "recv")) != -1) { switch(opt) { case 'r': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'e': cell.cp = SRSLTE_CP_EXT; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/channel/test/fading_channel_test.c b/lib/src/phy/channel/test/fading_channel_test.c index 6ad744a32..dcda2c6d0 100644 --- a/lib/src/phy/channel/test/fading_channel_test.c +++ b/lib/src/phy/channel/test/fading_channel_test.c @@ -67,13 +67,13 @@ static void parse_args(int argc, char** argv) model = argv[optind]; break; case 't': - duration_ms = (uint32_t)atof(argv[optind]); + duration_ms = (uint32_t)strtof(argv[optind], NULL); break; case 's': - srate = (uint32_t)atof(argv[optind]); + srate = (uint32_t)strtof(argv[optind], NULL); break; case 'r': - random_seed = (uint32_t)atoi(argv[optind]); + random_seed = (uint32_t)strtol(argv[optind], NULL, 10); break; #ifdef ENABLE_GUI case 'g': diff --git a/lib/src/phy/dft/test/ofdm_test.c b/lib/src/phy/dft/test/ofdm_test.c index 514fb4817..70523c360 100644 --- a/lib/src/phy/dft/test/ofdm_test.c +++ b/lib/src/phy/dft/test/ofdm_test.c @@ -54,13 +54,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "ner")) != -1) { switch (opt) { case 'n': - nof_prb = atoi(argv[optind]); + nof_prb = (int)strtol(argv[optind], NULL, 10); break; case 'e': cp = SRSLTE_CP_EXT; break; case 'r': - nof_repetitions = atoi(argv[optind]); + nof_repetitions = (int)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/fec/test/crc_test.c b/lib/src/phy/fec/test/crc_test.c index 8c062bc23..1e1523e64 100644 --- a/lib/src/phy/fec/test/crc_test.c +++ b/lib/src/phy/fec/test/crc_test.c @@ -47,10 +47,10 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nlps")) != -1) { switch (opt) { case 'n': - num_bits = atoi(argv[optind]); + num_bits = (int)strtol(argv[optind], NULL, 10); break; case 'l': - crc_length = atoi(argv[optind]); + crc_length = (int)strtol(argv[optind], NULL, 10); break; case 'p': crc_poly = (uint32_t) strtoul(argv[optind], NULL, 16); diff --git a/lib/src/phy/fec/test/rm_conv_test.c b/lib/src/phy/fec/test/rm_conv_test.c index 680de3d28..e513ffce8 100644 --- a/lib/src/phy/fec/test/rm_conv_test.c +++ b/lib/src/phy/fec/test/rm_conv_test.c @@ -41,10 +41,10 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "tr")) != -1) { switch (opt) { case 't': - nof_tx_bits = atoi(argv[optind]); + nof_tx_bits = (int)strtol(argv[optind], NULL, 10); break; case 'r': - nof_rx_bits = atoi(argv[optind]); + nof_rx_bits = (int)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/fec/test/rm_turbo_test.c b/lib/src/phy/fec/test/rm_turbo_test.c index 900a37feb..fa398c6e8 100644 --- a/lib/src/phy/fec/test/rm_turbo_test.c +++ b/lib/src/phy/fec/test/rm_turbo_test.c @@ -55,13 +55,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cei")) != -1) { switch (opt) { case 'c': - cb_idx = atoi(argv[optind]); + cb_idx = (int)strtol(argv[optind], NULL, 10); break; case 'e': - nof_e_bits = atoi(argv[optind]); + nof_e_bits = (int)strtol(argv[optind], NULL, 10); break; case 'i': - rv_idx = atoi(argv[optind]); + rv_idx = (int)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/fec/test/turbocoder_test.c b/lib/src/phy/fec/test/turbocoder_test.c index 97da3ef43..ef6f60993 100644 --- a/lib/src/phy/fec/test/turbocoder_test.c +++ b/lib/src/phy/fec/test/turbocoder_test.c @@ -43,7 +43,7 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "lv")) != -1) { switch (opt) { case 'l': - long_cb = atoi(argv[optind]); + long_cb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/fec/test/turbodecoder_test.c b/lib/src/phy/fec/test/turbodecoder_test.c index adabf5766..c0fe13f91 100644 --- a/lib/src/phy/fec/test/turbodecoder_test.c +++ b/lib/src/phy/fec/test/turbodecoder_test.c @@ -74,13 +74,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "kcinNledts")) != -1) { switch (opt) { case 'c': - nof_cb = atoi(argv[optind]); + nof_cb = (int)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'N': - nof_repetitions = atoi(argv[optind]); + nof_repetitions = (int)strtol(argv[optind], NULL, 10); break; case 'k': test_known_data = 1; @@ -89,16 +89,16 @@ void parse_args(int argc, char **argv) { test_errors = 1; break; case 'i': - nof_iterations = atoi(argv[optind]); + nof_iterations = (int)strtol(argv[optind], NULL, 10); break; case 'l': - frame_length = atoi(argv[optind]); + frame_length = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'd': - tdec_type = (srslte_tdec_impl_type_t) atoi(argv[optind]); + tdec_type = (srslte_tdec_impl_type_t)strtol(argv[optind], NULL, 10); break; case 'e': - ebno_db = atof(argv[optind]); + ebno_db = strtof(argv[optind], NULL); break; case 's': seed = (uint32_t) strtoul(argv[optind], NULL, 0); diff --git a/lib/src/phy/fec/test/viterbi_test.c b/lib/src/phy/fec/test/viterbi_test.c index 08beaee63..7dd37ec51 100644 --- a/lib/src/phy/fec/test/viterbi_test.c +++ b/lib/src/phy/fec/test/viterbi_test.c @@ -61,13 +61,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nlste")) != -1) { switch (opt) { case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'l': - frame_length = atoi(argv[optind]); + frame_length = (int)strtol(argv[optind], NULL, 10); break; case 'e': - ebno_db = atof(argv[optind]); + ebno_db = strtof(argv[optind], NULL); break; case 's': seed = (uint32_t) strtoul(argv[optind], NULL, 0); diff --git a/lib/src/phy/mimo/test/layermap_test.c b/lib/src/phy/mimo/test/layermap_test.c index eac3f552f..99189d61e 100644 --- a/lib/src/phy/mimo/test/layermap_test.c +++ b/lib/src/phy/mimo/test/layermap_test.c @@ -50,13 +50,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "mcln")) != -1) { switch (opt) { case 'n': - nof_symbols = atoi(argv[optind]); + nof_symbols = (int)strtol(argv[optind], NULL, 10); break; case 'c': - nof_cw = atoi(argv[optind]); + nof_cw = (int)strtol(argv[optind], NULL, 10); break; case 'l': - nof_layers = atoi(argv[optind]); + nof_layers = (int)strtol(argv[optind], NULL, 10); break; case 'm': mimo_type_name = argv[optind]; diff --git a/lib/src/phy/mimo/test/precoder_test.c b/lib/src/phy/mimo/test/precoder_test.c index d64b4c0ac..cf670b3df 100644 --- a/lib/src/phy/mimo/test/precoder_test.c +++ b/lib/src/phy/mimo/test/precoder_test.c @@ -65,32 +65,32 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "mplnrcdsg")) != -1) { switch (opt) { case 'n': - nof_symbols = atoi(argv[optind]); + nof_symbols = (int)strtol(argv[optind], NULL, 10); break; case 'p': - nof_tx_ports = atoi(argv[optind]); + nof_tx_ports = (int)strtol(argv[optind], NULL, 10); break; case 'r': - nof_rx_ports = atoi(argv[optind]); + nof_rx_ports = (int)strtol(argv[optind], NULL, 10); break; case 'l': - nof_layers = atoi(argv[optind]); + nof_layers = (int)strtol(argv[optind], NULL, 10); break; case 'm': mimo_type_name = argv[optind]; break; case 'c': - codebook_idx = (uint32_t) atoi(argv[optind]); + codebook_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'd': strncpy(decoder_type_name, argv[optind], 15); decoder_type_name[15] = 0; break; case 's': - snr_db = (float) atof(argv[optind]); + snr_db = strtof(argv[optind], NULL); break; case 'g': - scaling = (float) atof(argv[optind]); + scaling = strtof(argv[optind], NULL); break; default: usage(argv[0]); diff --git a/lib/src/phy/modem/test/modem_test.c b/lib/src/phy/modem/test/modem_test.c index 553b39918..a10962a1f 100644 --- a/lib/src/phy/modem/test/modem_test.c +++ b/lib/src/phy/modem/test/modem_test.c @@ -47,30 +47,30 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nm")) != -1) { switch (opt) { case 'n': - num_bits = atoi(argv[optind]); + num_bits = (int)strtol(argv[optind], NULL, 10); break; case 'm': - switch(atoi(argv[optind])) { - case 1: - modulation = SRSLTE_MOD_BPSK; - break; - case 2: - modulation = SRSLTE_MOD_QPSK; - break; - case 4: - modulation = SRSLTE_MOD_16QAM; - break; - case 6: - modulation = SRSLTE_MOD_64QAM; - break; - case 8: - modulation = SRSLTE_MOD_256QAM; - break; - default: - ERROR("Invalid modulation %d. Possible values: " - "(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64, 8: QAM256)\n", - atoi(argv[optind])); - break; + switch (strtol(argv[optind], NULL, 10)) { + case 1: + modulation = SRSLTE_MOD_BPSK; + break; + case 2: + modulation = SRSLTE_MOD_QPSK; + break; + case 4: + modulation = SRSLTE_MOD_16QAM; + break; + case 6: + modulation = SRSLTE_MOD_64QAM; + break; + case 8: + modulation = SRSLTE_MOD_256QAM; + break; + default: + ERROR("Invalid modulation %ld. Possible values: " + "(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64, 8: QAM256)\n", + strtol(argv[optind], NULL, 10)); + break; } break; default: diff --git a/lib/src/phy/modem/test/soft_demod_test.c b/lib/src/phy/modem/test/soft_demod_test.c index 24df18b83..2be4154d1 100644 --- a/lib/src/phy/modem/test/soft_demod_test.c +++ b/lib/src/phy/modem/test/soft_demod_test.c @@ -46,36 +46,36 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nmvf")) != -1) { switch (opt) { case 'n': - num_bits = atoi(argv[optind]); + num_bits = (int)strtol(argv[optind], NULL, 10); break; case 'f': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; break; case 'm': - switch(atoi(argv[optind])) { - case 1: - modulation = SRSLTE_MOD_BPSK; - break; - case 2: - modulation = SRSLTE_MOD_QPSK; - break; - case 4: - modulation = SRSLTE_MOD_16QAM; - break; - case 6: - modulation = SRSLTE_MOD_64QAM; - break; - case 8: - modulation = SRSLTE_MOD_256QAM; - break; - default: - ERROR("Invalid modulation %d. Possible values: " - "(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", - atoi(argv[optind])); - break; + switch (strtol(argv[optind], NULL, 10)) { + case 1: + modulation = SRSLTE_MOD_BPSK; + break; + case 2: + modulation = SRSLTE_MOD_QPSK; + break; + case 4: + modulation = SRSLTE_MOD_16QAM; + break; + case 6: + modulation = SRSLTE_MOD_64QAM; + break; + case 8: + modulation = SRSLTE_MOD_256QAM; + break; + default: + ERROR("Invalid modulation %d. Possible values: " + "(1: BPSK, 2: QPSK, 4: QAM16, 6: QAM64)\n", + (int)strtol(argv[optind], NULL, 10)); + break; } break; default: diff --git a/lib/src/phy/phch/test/npbch_file_test.c b/lib/src/phy/phch/test/npbch_file_test.c index bbe081742..3675ae564 100644 --- a/lib/src/phy/phch/test/npbch_file_test.c +++ b/lib/src/phy/phch/test/npbch_file_test.c @@ -77,25 +77,25 @@ void parse_args(int argc, char** argv) input_file_name = argv[optind]; break; case 'l': - cell.n_id_ncell = atoi(argv[optind]); + cell.n_id_ncell = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.base.nof_prb = atoi(argv[optind]); + cell.base.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 't': - do_chest = atoi(argv[optind]); + do_chest = (strtol(argv[optind], NULL, 10) != 0); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 's': - sf_idx = atoi(argv[optind]) % 10; + sf_idx = (int)(strtol(argv[optind], NULL, 10) % 10); break; case 'v': srslte_verbose++; break; case 'r': - nf = atoi(argv[optind]); + nf = (int)strtol(argv[optind], NULL, 10); break; case 'R': cell.is_r14 = true; diff --git a/lib/src/phy/phch/test/npbch_test.c b/lib/src/phy/phch/test/npbch_test.c index 9a01a202a..43866206e 100644 --- a/lib/src/phy/phch/test/npbch_test.c +++ b/lib/src/phy/phch/test/npbch_test.c @@ -49,13 +49,13 @@ void parse_args(int argc, char** argv) while ((opt = getopt(argc, argv, "cpnv")) != -1) { switch (opt) { case 'p': - cell.base.nof_ports = atoi(argv[optind]); + cell.base.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.base.nof_prb = atoi(argv[optind]); + cell.base.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.base.id = atoi(argv[optind]); + cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/pbch_file_test.c b/lib/src/phy/phch/test/pbch_file_test.c index 6ee45252b..5544bd183 100644 --- a/lib/src/phy/phch/test/pbch_file_test.c +++ b/lib/src/phy/phch/test/pbch_file_test.c @@ -71,13 +71,13 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/pbch_test.c b/lib/src/phy/phch/test/pbch_test.c index ea3ec6a77..725df21ab 100644 --- a/lib/src/phy/phch/test/pbch_test.c +++ b/lib/src/phy/phch/test/pbch_test.c @@ -52,13 +52,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cpnv")) != -1) { switch(opt) { case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/pcfich_file_test.c b/lib/src/phy/phch/test/pcfich_file_test.c index 056e15904..f44ea1be7 100644 --- a/lib/src/phy/phch/test/pcfich_file_test.c +++ b/lib/src/phy/phch/test/pcfich_file_test.c @@ -69,16 +69,16 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'd': use_standard_lte_rates = true; break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': matlab_file_name = argv[optind]; diff --git a/lib/src/phy/phch/test/pcfich_test.c b/lib/src/phy/phch/test/pcfich_test.c index d4d32eb42..acfe0105b 100644 --- a/lib/src/phy/phch/test/pcfich_test.c +++ b/lib/src/phy/phch/test/pcfich_test.c @@ -51,13 +51,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cpnv")) != -1) { switch(opt) { case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/pdcch_file_test.c b/lib/src/phy/phch/test/pdcch_file_test.c index daea48624..757382676 100644 --- a/lib/src/phy/phch/test/pdcch_file_test.c +++ b/lib/src/phy/phch/test/pdcch_file_test.c @@ -75,7 +75,7 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': rnti = strtoul(argv[optind], NULL, 0); @@ -84,13 +84,13 @@ void parse_args(int argc, char **argv) { max_frames = strtoul(argv[optind], NULL, 0); break; case 'f': - cfi = atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': dci_format = srslte_dci_format_from_string(argv[optind]); diff --git a/lib/src/phy/phch/test/pdcch_test.c b/lib/src/phy/phch/test/pdcch_test.c index 2d6cdc63c..c942fed7f 100644 --- a/lib/src/phy/phch/test/pdcch_test.c +++ b/lib/src/phy/phch/test/pdcch_test.c @@ -57,19 +57,19 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cfpndvAx")) != -1) { switch (opt) { case 'p': - cell.nof_ports = (uint32_t) atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'f': - cfi = (uint32_t) atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = (uint32_t) atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = (uint32_t) atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'A': - nof_rx_ant = (uint32_t) atoi(argv[optind]); + nof_rx_ant = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'd': print_dci_table = true; diff --git a/lib/src/phy/phch/test/pdsch_pdcch_file_test.c b/lib/src/phy/phch/test/pdsch_pdcch_file_test.c index 5aeb7059b..16226c3fe 100644 --- a/lib/src/phy/phch/test/pdsch_pdcch_file_test.c +++ b/lib/src/phy/phch/test/pdsch_pdcch_file_test.c @@ -75,10 +75,10 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - sf_idx = atoi(argv[optind]); + sf_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': rnti = strtoul(argv[optind], NULL, 0); @@ -87,13 +87,13 @@ void parse_args(int argc, char **argv) { max_frames = strtoul(argv[optind], NULL, 0); break; case 'f': - cfi = atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': dci_format = srslte_dci_format_from_string(argv[optind]); diff --git a/lib/src/phy/phch/test/pdsch_test.c b/lib/src/phy/phch/test/pdsch_test.c index 9077d08eb..fc9d8524f 100644 --- a/lib/src/phy/phch/test/pdsch_test.c +++ b/lib/src/phy/phch/test/pdsch_test.c @@ -87,46 +87,46 @@ void parse_args(int argc, char **argv) { input_file = argv[optind]; break; case 'm': - mcs[0] = (uint32_t) atoi(argv[optind]); + mcs[0] = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'b': use_8_bit = true; break; case 'M': - mcs[1] = (uint32_t) atoi(argv[optind]); + mcs[1] = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - subframe = atoi(argv[optind]); + subframe = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'X': - M = (uint32_t) atoi(argv[optind]); + M = (int)strtol(argv[optind], NULL, 10); break; case 'r': - rv_idx[0] = (uint32_t) atoi(argv[optind]); + rv_idx[0] = (int)strtol(argv[optind], NULL, 10); break; case 't': - rv_idx[1] = (uint32_t) atoi(argv[optind]); + rv_idx[1] = (int)strtol(argv[optind], NULL, 10); break; case 'R': - rnti = atoi(argv[optind]); + rnti = (uint16_t)strtol(argv[optind], NULL, 10); break; case 'F': - cfi = atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'x': - tm = (srslte_tm_t)atoi(argv[optind]) - 1; + tm = (srslte_tm_t)(strtol(argv[optind], NULL, 10) - 1); break; case 'p': - pmi = (uint32_t) atoi(argv[optind]); + pmi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'a': - nof_rx_antennas = (uint32_t) atoi(argv[optind]); + nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'w': tb_cw_swap = true; diff --git a/lib/src/phy/phch/test/phich_file_test.c b/lib/src/phy/phch/test/phich_file_test.c index 3a0f14d6f..9f8d1e777 100644 --- a/lib/src/phy/phch/test/phich_file_test.c +++ b/lib/src/phy/phch/test/phich_file_test.c @@ -79,10 +79,10 @@ void parse_args(int argc, char **argv) { matlab_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'f': - nof_ctrl_symbols = atoi(argv[optind]); + nof_ctrl_symbols = (int)strtol(argv[optind], NULL, 10); break; case 'g': if (!strcmp(argv[optind], "1/6")) { @@ -101,10 +101,10 @@ void parse_args(int argc, char **argv) { cell.phich_length = SRSLTE_PHICH_EXT; break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/phich_test.c b/lib/src/phy/phch/test/phich_test.c index a0e87983a..42db813ea 100644 --- a/lib/src/phy/phch/test/phich_test.c +++ b/lib/src/phy/phch/test/phich_test.c @@ -57,13 +57,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cpnvgel")) != -1) { switch(opt) { case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'g': if (!strcmp(argv[optind], "1/6")) { diff --git a/lib/src/phy/phch/test/pmch_file_test.c b/lib/src/phy/phch/test/pmch_file_test.c index a4079868f..683addbdd 100644 --- a/lib/src/phy/phch/test/pmch_file_test.c +++ b/lib/src/phy/phch/test/pmch_file_test.c @@ -75,22 +75,22 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - sf_idx = atoi(argv[optind]); + sf_idx = (int)strtol(argv[optind], NULL, 10); break; case 'f': - cfi = atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - cell.nof_ports = atoi(argv[optind]); + cell.nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'M': - mbsfn_area_id = atoi(argv[optind]); + mbsfn_area_id = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/pmch_test.c b/lib/src/phy/phch/test/pmch_test.c index 28499b79c..d81e32d7b 100644 --- a/lib/src/phy/phch/test/pmch_test.c +++ b/lib/src/phy/phch/test/pmch_test.c @@ -83,31 +83,31 @@ void parse_args(int argc, char **argv) { input_file = argv[optind]; break; case 'm': - mcs_idx = (uint32_t) atoi(argv[optind]); + mcs_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - subframe = atoi(argv[optind]); + subframe = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': - rv_idx[0] = (uint32_t) atoi(argv[optind]); + rv_idx[0] = (int)strtol(argv[optind], NULL, 10); break; case 'R': - rnti = atoi(argv[optind]); + rnti = (uint16_t)strtol(argv[optind], NULL, 10); break; case 'F': - cfi = atoi(argv[optind]); + cfi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - pmi = (uint32_t) atoi(argv[optind]); + pmi = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'a': - nof_rx_antennas = (uint32_t) atoi(argv[optind]); + nof_rx_antennas = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/phch/test/prach_test.c b/lib/src/phy/phch/test/prach_test.c index b866c1eff..a79287180 100644 --- a/lib/src/phy/phch/test/prach_test.c +++ b/lib/src/phy/phch/test/prach_test.c @@ -50,16 +50,16 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nfrz")) != -1) { switch (opt) { case 'n': - nof_prb = atoi(argv[optind]); + nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'f': - config_idx = atoi(argv[optind]); + config_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': - root_seq_idx = atoi(argv[optind]); + root_seq_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'z': - zero_corr_zone = atoi(argv[optind]); + zero_corr_zone = (uint32_t)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/phch/test/prach_test_multi.c b/lib/src/phy/phch/test/prach_test_multi.c index 8d8817977..874e9403a 100644 --- a/lib/src/phy/phch/test/prach_test_multi.c +++ b/lib/src/phy/phch/test/prach_test_multi.c @@ -52,19 +52,19 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "Nfrzn")) != -1) { switch (opt) { case 'N': - nof_prb = atoi(argv[optind]); + nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'f': - preamble_format = atoi(argv[optind]); + preamble_format = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': - root_seq_idx = atoi(argv[optind]); + root_seq_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'z': - zero_corr_zone = atoi(argv[optind]); + zero_corr_zone = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - n_seqs = atoi(argv[optind]); + n_seqs = (uint32_t)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/phch/test/prach_test_usrp.c b/lib/src/phy/phch/test/prach_test_usrp.c index fb18def7b..1f0846e58 100644 --- a/lib/src/phy/phch/test/prach_test_usrp.c +++ b/lib/src/phy/phch/test/prach_test_usrp.c @@ -73,41 +73,41 @@ void parse_args(int argc, char **argv) { output_filename = argv[optind]; break; case 'f': - uhd_freq = atof(argv[optind]); + uhd_freq = strtof(argv[optind], NULL); break; case 'g': - uhd_rx_gain = atof(argv[optind]); + uhd_rx_gain = strtof(argv[optind], NULL); break; case 'G': - uhd_tx_gain = atof(argv[optind]); + uhd_tx_gain = strtof(argv[optind], NULL); break; case 'P': - preamble_format = atoi(argv[optind]); + preamble_format = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'O': - frequency_offset = atoi(argv[optind]); + frequency_offset = (uint32_t)strtol(argv[optind], NULL, 10); break; case 't': - timeadv = atof(argv[optind]); + timeadv = strtof(argv[optind], NULL); break; case 'p': - nof_prb = atoi(argv[optind]); + nof_prb = (int)strtol(argv[optind], NULL, 10); if (!srslte_nofprb_isvalid(nof_prb)) { ERROR("Invalid number of UL RB %d\n", nof_prb); exit(-1); } break; case 'F': - preamble_format = atoi(argv[optind]); + preamble_format = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'r': - root_seq_idx = atoi(argv[optind]); + root_seq_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - seq_idx = atoi(argv[optind]); + seq_idx = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'z': - zero_corr_zone = atoi(argv[optind]); + zero_corr_zone = (uint32_t)strtol(argv[optind], NULL, 10); break; default: usage(argv[0]); diff --git a/lib/src/phy/phch/test/pucch_test.c b/lib/src/phy/phch/test/pucch_test.c index b03c241d9..8dfdfe3dc 100644 --- a/lib/src/phy/phch/test/pucch_test.c +++ b/lib/src/phy/phch/test/pucch_test.c @@ -56,13 +56,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "csNnqv")) != -1) { switch(opt) { case 's': - subframe = atoi(argv[optind]); + subframe = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - cell.nof_prb = atoi(argv[optind]); + cell.nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'c': - cell.id = atoi(argv[optind]); + cell.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'q': test_cqi_only = true; diff --git a/lib/src/phy/scrambling/test/scrambling_test.c b/lib/src/phy/scrambling/test/scrambling_test.c index 455c8c7d1..7934abe1c 100644 --- a/lib/src/phy/scrambling/test/scrambling_test.c +++ b/lib/src/phy/scrambling/test/scrambling_test.c @@ -48,10 +48,10 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "csefl")) != -1) { switch (opt) { case 'c': - cell_id = atoi(argv[optind]); + cell_id = (int)strtol(argv[optind], NULL, 10); break; case 'l': - nof_bits = atoi(argv[optind]); + nof_bits = (int)strtol(argv[optind], NULL, 10); break; case 'e': cp = SRSLTE_CP_EXT; diff --git a/lib/src/phy/sync/test/cfo_test.c b/lib/src/phy/sync/test/cfo_test.c index bdeccacf2..0fbecd525 100644 --- a/lib/src/phy/sync/test/cfo_test.c +++ b/lib/src/phy/sync/test/cfo_test.c @@ -44,10 +44,10 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "nf")) != -1) { switch (opt) { case 'n': - num_samples = atoi(argv[optind]); + num_samples = (int)strtol(argv[optind], NULL, 10); break; case 'f': - freq = atof(argv[optind]); + freq = strtof(argv[optind], NULL); break; default: usage(argv[0]); diff --git a/lib/src/phy/sync/test/npss_file.c b/lib/src/phy/sync/test/npss_file.c index b53fcf156..39824b562 100644 --- a/lib/src/phy/sync/test/npss_file.c +++ b/lib/src/phy/sync/test/npss_file.c @@ -76,19 +76,19 @@ void parse_args(int argc, char** argv) input_file_name = argv[optind]; break; case 't': - threshold = atof(argv[optind]); + threshold = strtof(argv[optind], NULL); break; case 'o': - file_offset = atoi(argv[optind]); + file_offset = (int)strtol(argv[optind], NULL, 10); break; case 'l': - N_id_2_sync = atoi(argv[optind]); + N_id_2_sync = (int)strtol(argv[optind], NULL, 10); break; case 's': save_frame_to_file = true; break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/sync/test/npss_test.c b/lib/src/phy/sync/test/npss_test.c index 06dfab29b..947aad139 100644 --- a/lib/src/phy/sync/test/npss_test.c +++ b/lib/src/phy/sync/test/npss_test.c @@ -51,7 +51,7 @@ void parse_args(int argc, char** argv) while ((opt = getopt(argc, argv, "lv")) != -1) { switch (opt) { case 'l': - input_len = atoi(argv[optind]); + input_len = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose = SRSLTE_VERBOSE_DEBUG; diff --git a/lib/src/phy/sync/test/npss_usrp.c b/lib/src/phy/sync/test/npss_usrp.c index f7e93cd8a..8c61faccd 100644 --- a/lib/src/phy/sync/test/npss_usrp.c +++ b/lib/src/phy/sync/test/npss_usrp.c @@ -84,26 +84,26 @@ void parse_args(int argc, char** argv) has_cfo_corr = false; break; case 'c': - cfo_fixed = atof(argv[optind]); + cfo_fixed = strtof(argv[optind], NULL); break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 't': - threshold = atof(argv[optind]); + threshold = strtof(argv[optind], NULL); break; case 'i': - cell.base.id = atoi(argv[optind]); + cell.base.id = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': save_frame_to_file = true; disable_plots = true; break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'd': disable_plots = true; diff --git a/lib/src/phy/sync/test/nsss_test.c b/lib/src/phy/sync/test/nsss_test.c index b2646fbfd..21b1958fd 100644 --- a/lib/src/phy/sync/test/nsss_test.c +++ b/lib/src/phy/sync/test/nsss_test.c @@ -66,13 +66,13 @@ void parse_args(int argc, char** argv) input_file_name = argv[optind]; break; case 'c': - n_id_ncell = atoi(argv[optind]); + n_id_ncell = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - sfn = atoi(argv[optind]); + sfn = (int)strtol(argv[optind], NULL, 10); break; case 'r': - max_num_sf = atoi(argv[optind]); + max_num_sf = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose = SRSLTE_VERBOSE_DEBUG; diff --git a/lib/src/phy/sync/test/nsss_usrp.c b/lib/src/phy/sync/test/nsss_usrp.c index c6f63bea4..aa1fdd763 100644 --- a/lib/src/phy/sync/test/nsss_usrp.c +++ b/lib/src/phy/sync/test/nsss_usrp.c @@ -75,22 +75,22 @@ void parse_args(int argc, char** argv) has_cfo_corr = false; break; case 'c': - cfo_fixed = atof(argv[optind]); + cfo_fixed = strtof(argv[optind], NULL); break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 't': - threshold = atof(argv[optind]); + threshold = strtof(argv[optind], NULL); break; case 'i': - cell.n_id_ncell = atoi(argv[optind]); + cell.n_id_ncell = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose++; diff --git a/lib/src/phy/sync/test/pss_file.c b/lib/src/phy/sync/test/pss_file.c index 3b89e32c0..72ada1ff2 100644 --- a/lib/src/phy/sync/test/pss_file.c +++ b/lib/src/phy/sync/test/pss_file.c @@ -72,25 +72,25 @@ void parse_args(int argc, char **argv) { input_file_name = argv[optind]; break; case 't': - threshold = atof(argv[optind]); + threshold = strtof(argv[optind], NULL); break; case 'e': cp = SRSLTE_CP_EXT; break; case 'i': - cell_id = atoi(argv[optind]); + cell_id = (int)strtol(argv[optind], NULL, 10); break; case 'o': - file_offset = atoi(argv[optind]); + file_offset = (int)strtol(argv[optind], NULL, 10); break; case 'l': - N_id_2_sync = atoi(argv[optind]); + N_id_2_sync = (int)strtol(argv[optind], NULL, 10); break; case 's': - fft_size = atoi(argv[optind]); + fft_size = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'd': disable_plots = true; diff --git a/lib/src/phy/sync/test/pss_usrp.c b/lib/src/phy/sync/test/pss_usrp.c index dd7168ff4..a42a1ff52 100644 --- a/lib/src/phy/sync/test/pss_usrp.c +++ b/lib/src/phy/sync/test/pss_usrp.c @@ -75,31 +75,31 @@ void parse_args(int argc, char **argv) { rf_args = argv[optind]; break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); break; case 'f': - rf_freq = atof(argv[optind]); + rf_freq = strtof(argv[optind], NULL); break; case 't': - threshold = atof(argv[optind]); + threshold = strtof(argv[optind], NULL); break; case 'e': cp = SRSLTE_CP_EXT; break; case 'i': - cell_id = atoi(argv[optind]); + cell_id = (int)strtol(argv[optind], NULL, 10); break; case 'T': tdd_mode = true; break; case 'l': - N_id_2_sync = atoi(argv[optind]); + N_id_2_sync = (int)strtol(argv[optind], NULL, 10); break; case 's': - fft_size = atoi(argv[optind]); + fft_size = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'n': - nof_frames = atoi(argv[optind]); + nof_frames = (int)strtol(argv[optind], NULL, 10); break; case 'd': disable_plots = true; diff --git a/lib/src/phy/sync/test/sync_nbiot_test.c b/lib/src/phy/sync/test/sync_nbiot_test.c index 6abac8704..b8877a733 100644 --- a/lib/src/phy/sync/test/sync_nbiot_test.c +++ b/lib/src/phy/sync/test/sync_nbiot_test.c @@ -63,13 +63,13 @@ void parse_args(int argc, char** argv) input_file_name = argv[optind]; break; case 'c': - cfo = atof(argv[optind]); + cfo = strtof(argv[optind], NULL); break; case 'g': - snr = atof(argv[optind]); + snr = strtof(argv[optind], NULL); break; case 'o': - offset = atoi(argv[optind]); + offset = (int)strtol(argv[optind], NULL, 10); break; case 'v': srslte_verbose = SRSLTE_VERBOSE_DEBUG; diff --git a/lib/src/phy/sync/test/sync_test.c b/lib/src/phy/sync/test/sync_test.c index 7f90a4f2c..b0e28725e 100644 --- a/lib/src/phy/sync/test/sync_test.c +++ b/lib/src/phy/sync/test/sync_test.c @@ -51,13 +51,13 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "cpoev")) != -1) { switch (opt) { case 'c': - cell_id = atoi(argv[optind]); + cell_id = (int)strtol(argv[optind], NULL, 10); break; case 'p': - nof_prb = atoi(argv[optind]); + nof_prb = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'o': - offset = atoi(argv[optind]); + offset = (int)strtol(argv[optind], NULL, 10); break; case 'e': cp = SRSLTE_CP_EXT; diff --git a/lib/src/phy/utils/test/dft_test.c b/lib/src/phy/utils/test/dft_test.c index 0b1e25225..f21ac6184 100644 --- a/lib/src/phy/utils/test/dft_test.c +++ b/lib/src/phy/utils/test/dft_test.c @@ -51,7 +51,7 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "Nbmnd")) != -1) { switch (opt) { case 'N': - N = atoi(argv[optind]); + N = (int)strtol(argv[optind], NULL, 10); break; case 'b': forward = false; diff --git a/lib/src/radio/test/benchmark_radio.cc b/lib/src/radio/test/benchmark_radio.cc index 6924c55a3..a6b60450e 100644 --- a/lib/src/radio/test/benchmark_radio.cc +++ b/lib/src/radio/test/benchmark_radio.cc @@ -61,7 +61,7 @@ static sem_t plot_sem; static uint32_t plot_sf_idx = 0; static plot_real_t fft_plot[SRSLTE_MAX_RADIOS] = {}; static cf_t* fft_plot_buffer[SRSLTE_MAX_RADIOS] = {}; -static float* fft_plot_temp = NULL; +static float* fft_plot_temp = nullptr; static uint32_t fft_plot_buffer_size; srslte_dft_plan_t dft_spectrum = {}; #endif /* ENABLE_GUI */ @@ -94,10 +94,10 @@ void parse_args(int argc, char **argv) { while ((opt = getopt(argc, argv, "foabcderpsStvhmFxwg")) != -1) { switch (opt) { case 'f': - freq = atof(argv[optind]); + freq = strtof(argv[optind], NULL); break; case 'g': - rf_gain = atof(argv[optind]); + rf_gain = strtof(argv[optind], NULL); agc_enable = false; break; case 'o': @@ -116,16 +116,16 @@ void parse_args(int argc, char **argv) { radios_args[2][63] = '\0'; break; case 'r': - nof_radios = (uint32_t)atoi(argv[optind]); + nof_radios = (uint32_t)strtol(argv[optind], NULL, 10); break; case 'p': - nof_ports = (uint32_t)atoi(argv[optind]); + nof_ports = (uint32_t)strtol(argv[optind], NULL, 10); break; case 's': - srate = atof(argv[optind]); + srate = strtof(argv[optind], NULL); break; case 't': - duration = atof(argv[optind]); + duration = strtof(argv[optind], NULL); break; case 'm': measure_delay ^= true; diff --git a/srsepc/src/hss/hss.cc b/srsepc/src/hss/hss.cc index d16bf8a8e..7e3122b62 100644 --- a/srsepc/src/hss/hss.cc +++ b/srsepc/src/hss/hss.cc @@ -131,7 +131,7 @@ bool hss::read_db_file(std::string db_filename) m_hss_log->error("Neither XOR nor MILENAGE configured.\n"); return false; } - ue_ctx->imsi = atoll(split[2].c_str()); + ue_ctx->imsi = strtoull(split[2].c_str(), nullptr, 10); get_uint_vec_from_hex_str(split[3], ue_ctx->key, 16); if (split[4] == std::string("op")) { ue_ctx->op_configured = true; @@ -155,7 +155,7 @@ bool hss::read_db_file(std::string db_filename) m_hss_log->debug_hex(ue_ctx->opc, 16, "User OPc : "); m_hss_log->debug_hex(ue_ctx->amf, 2, "AMF : "); m_hss_log->debug_hex(ue_ctx->sqn, 6, "SQN : "); - ue_ctx->qci = atoi(split[8].c_str()); + ue_ctx->qci = (uint16_t)strtol(split[8].c_str(), nullptr, 10); m_hss_log->debug("Default Bearer QCI: %d\n", ue_ctx->qci); if (split[9] == std::string("dynamic")) { diff --git a/srsue/hdr/stack/upper/nas.h b/srsue/hdr/stack/upper/nas.h index afe653c3c..62967dcbb 100644 --- a/srsue/hdr/stack/upper/nas.h +++ b/srsue/hdr/stack/upper/nas.h @@ -221,7 +221,7 @@ private: if(line.substr(0,len).compare(key)) { return false; } - *var = (T)atoi(line.substr(len).c_str()); + *var = (T)strtol(line.substr(len).c_str(), NULL, 10); return true; } @@ -248,7 +248,7 @@ private: std::string substr; getline(ss, substr, ','); if (not substr.empty()) { - list.push_back(atoi(substr.c_str())); + list.push_back(strtol(substr.c_str(), nullptr, 10)); } } return list; diff --git a/srsue/test/ttcn3/hdr/ttcn3_ue.h b/srsue/test/ttcn3/hdr/ttcn3_ue.h index 8f1370347..b21b78ed9 100644 --- a/srsue/test/ttcn3/hdr/ttcn3_ue.h +++ b/srsue/test/ttcn3/hdr/ttcn3_ue.h @@ -55,7 +55,7 @@ public: args.stack.rrc.feature_group = 0xe6041000; args.stack.rrc.ue_category_str = SRSLTE_UE_CATEGORY_DEFAULT; - args.stack.rrc.ue_category = atoi(args.stack.rrc.ue_category_str.c_str()); + args.stack.rrc.ue_category = strtol(args.stack.rrc.ue_category_str.c_str(), nullptr, 10); args.stack.rrc.nof_supported_bands = 1; args.stack.rrc.supported_bands[0] = 7; args.stack.rrc.release = 8;