From 02856704c829bb900165946219b6a1881d271462 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 Jan 2018 10:32:26 +0100 Subject: [PATCH] more coverity fixes --- lib/src/phy/phch/test/pmch_test.c | 3 ++- lib/src/phy/rf/rf_uhd_imp.c | 3 +-- srsenb/test/upper/ip_test.cc | 5 +++++ srsue/src/phy/phch_worker.cc | 13 ++++--------- srsue/src/upper/nas.cc | 8 ++++---- srsue/test/mac/mac_test.cc | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/lib/src/phy/phch/test/pmch_test.c b/lib/src/phy/phch/test/pmch_test.c index bf415e692..a69b5d075 100644 --- a/lib/src/phy/phch/test/pmch_test.c +++ b/lib/src/phy/phch/test/pmch_test.c @@ -102,7 +102,8 @@ void parse_args(int argc, char **argv) { cfi = atoi(argv[optind]); break; case 'x': - strncpy(mimo_type_str, argv[optind], 32); + strncpy(mimo_type_str, argv[optind], 31); + mimo_type_str[31] = 0; break; case 'p': pmi = (uint32_t) atoi(argv[optind]); diff --git a/lib/src/phy/rf/rf_uhd_imp.c b/lib/src/phy/rf/rf_uhd_imp.c index c57a63095..0fc70c547 100644 --- a/lib/src/phy/rf/rf_uhd_imp.c +++ b/lib/src/phy/rf/rf_uhd_imp.c @@ -711,13 +711,12 @@ int rf_uhd_recv_with_time(void *h, } int rf_uhd_recv_with_time_multi(void *h, - void **data, + void *data[SRSLTE_MAX_PORTS], uint32_t nsamples, bool blocking, time_t *secs, double *frac_secs) { - rf_uhd_handler_t *handler = (rf_uhd_handler_t*) h; uhd_rx_metadata_handle *md = &handler->rx_md_first; size_t rxd_samples = 0; diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index 2b789cf27..746f95ab5 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -609,6 +609,7 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(tun_fd, TUNSETIFF, &ifr)) { perror("ioctl1"); + close(tun_fd); return -1; } @@ -617,12 +618,14 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCGIFFLAGS, &ifr)) { perror("socket"); + close(tun_fd); return -1; } ifr.ifr_flags |= IFF_UP | IFF_RUNNING; if(0 > ioctl(sock, SIOCSIFFLAGS, &ifr)) { perror("ioctl2"); + close(tun_fd); return -1; } @@ -633,6 +636,7 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFADDR, &ifr)) { perror("ioctl"); + close(tun_fd); return -1; } ifr.ifr_netmask.sa_family = AF_INET; @@ -640,6 +644,7 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFNETMASK, &ifr)) { perror("ioctl"); + close(tun_fd); return -1; } diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index df0d3f458..771737c9e 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -223,13 +223,11 @@ void phch_worker::work_imp() bool ul_grant_available = false; bool dl_ack[SRSLTE_MAX_CODEWORDS] = {false}; - mac_interface_phy::mac_grant_t dl_mac_grant; - mac_interface_phy::tb_action_dl_t dl_action; - bzero(&dl_action, sizeof(mac_interface_phy::tb_action_dl_t)); + mac_interface_phy::mac_grant_t dl_mac_grant = {}; + mac_interface_phy::tb_action_dl_t dl_action = {}; - mac_interface_phy::mac_grant_t ul_mac_grant; - mac_interface_phy::tb_action_ul_t ul_action; - bzero(&ul_action, sizeof(mac_interface_phy::tb_action_ul_t)); + mac_interface_phy::mac_grant_t ul_mac_grant = {}; + mac_interface_phy::tb_action_ul_t ul_action = {}; /** Calculate RSSI on the input signal before generating the output */ @@ -1152,10 +1150,7 @@ void phch_worker::encode_srs() float tx_power = srslte_ue_ul_srs_power(&ue_ul, phy->pathloss); float gain = set_power(tx_power); - uint32_t fi = srslte_vec_max_fi((float*) signal_buffer, SRSLTE_SF_LEN_PRB(cell.nof_prb)); - float *f = (float*) signal_buffer; Info("SRS: power=%.2f dBm, tti_tx=%d%s\n", tx_power, TTI_TX(tti), timestr); - } void phch_worker::enable_pregen_signals(bool enabled) diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index 9a9015af7..67305aaa3 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -193,9 +193,9 @@ void nas::notify_connection_setup() { } void nas::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { - uint8 pd; - uint8 msg_type; - uint8 sec_hdr_type; + uint8 pd = 0; + uint8 msg_type = 0; + uint8 sec_hdr_type = 0; bool mac_valid = false; nas_log->info_hex(pdu->msg, pdu->N_bytes, "DL %s PDU", rrc->get_rb_name(lcid).c_str()); @@ -216,7 +216,7 @@ void nas::write_pdu(uint32_t lcid, byte_buffer_t *pdu) { case LIBLTE_MME_SECURITY_HDR_TYPE_INTEGRITY_AND_CIPHERED_WITH_NEW_EPS_SECURITY_CONTEXT: break; default: - nas_log->error("Not handling NAS message with SEC_HDR_TYPE=%02X\n",msg_type); + nas_log->error("Not handling NAS message with SEC_HDR_TYPE=%02X\n", sec_hdr_type); pool->deallocate(pdu); break; } diff --git a/srsue/test/mac/mac_test.cc b/srsue/test/mac/mac_test.cc index 4cb47e9f8..324189427 100644 --- a/srsue/test/mac/mac_test.cc +++ b/srsue/test/mac/mac_test.cc @@ -132,7 +132,7 @@ void setup_mac_phy_sib2(LIBLTE_RRC_SYS_INFO_BLOCK_TYPE_2_STRUCT *sib2, srsue::ma memcpy(&common.pusch_cnfg, &sib2->rr_config_common_sib.pusch_cnfg, sizeof(LIBLTE_RRC_PUSCH_CONFIG_COMMON_STRUCT)); memcpy(&common.pucch_cnfg, &sib2->rr_config_common_sib.pucch_cnfg, sizeof(LIBLTE_RRC_PUCCH_CONFIG_COMMON_STRUCT)); memcpy(&common.ul_pwr_ctrl, &sib2->rr_config_common_sib.ul_pwr_ctrl, sizeof(LIBLTE_RRC_UL_POWER_CONTROL_COMMON_STRUCT)); - memcpy(&common.prach_cnfg, &sib2->rr_config_common_sib.prach_cnfg, sizeof(LIBLTE_RRC_PRACH_CONFIG_STRUCT)); + memcpy(&common.prach_cnfg, &sib2->rr_config_common_sib.prach_cnfg, sizeof(LIBLTE_RRC_PRACH_CONFIG_SIB_STRUCT)); if (sib2->rr_config_common_sib.srs_ul_cnfg.present) { memcpy(&common.srs_ul_cnfg, &sib2->rr_config_common_sib.srs_ul_cnfg, sizeof(LIBLTE_RRC_SRS_UL_CONFIG_COMMON_STRUCT)); } else {