From d500bdbc240b43b82ba24e700204a0bbd4362709 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Wed, 31 Jan 2018 12:35:46 +0100 Subject: [PATCH] fix more coverity issues --- lib/src/phy/mimo/test/precoder_test.c | 3 ++- srsenb/src/mac/mac.cc | 2 +- srsenb/src/mac/ue.cc | 4 ++-- srsenb/test/upper/ip_test.cc | 8 ++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/src/phy/mimo/test/precoder_test.c b/lib/src/phy/mimo/test/precoder_test.c index 589e3d51c..ec022319f 100644 --- a/lib/src/phy/mimo/test/precoder_test.c +++ b/lib/src/phy/mimo/test/precoder_test.c @@ -82,7 +82,8 @@ void parse_args(int argc, char **argv) { codebook_idx = (uint32_t) atoi(argv[optind]); break; case 'd': - strncpy(decoder_type_name, argv[optind], 16); + strncpy(decoder_type_name, argv[optind], 15); + decoder_type_name[15] = 0; break; case 's': snr_db = (float) atof(argv[optind]); diff --git a/srsenb/src/mac/mac.cc b/srsenb/src/mac/mac.cc index f7a4d5b55..c710534ac 100644 --- a/srsenb/src/mac/mac.cc +++ b/srsenb/src/mac/mac.cc @@ -392,7 +392,7 @@ int mac::rach_detected(uint32_t tti, uint32_t preamble_idx, uint32_t time_adv) // Find empty slot for pending rars uint32_t ra_id=0; - while(pending_rars[ra_id].temp_crnti && ra_idce_type()) { @@ -289,7 +289,7 @@ bool ue::process_ce(srslte::sch_subh *subh) { break; case srslte::sch_subh::LONG_BSR: subh->get_bsr(buff_size); - for (int idx=0;idx<4;idx++) { + for (idx=0;idx<4;idx++) { for (uint32_t i=0;iul_bsr(rnti, lc_groups[idx][i], buff_size[idx]); } diff --git a/srsenb/test/upper/ip_test.cc b/srsenb/test/upper/ip_test.cc index 746f95ab5..0e84f6471 100644 --- a/srsenb/test/upper/ip_test.cc +++ b/srsenb/test/upper/ip_test.cc @@ -618,6 +618,7 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCGIFFLAGS, &ifr)) { perror("socket"); + close(sock); close(tun_fd); return -1; } @@ -625,10 +626,13 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFFLAGS, &ifr)) { perror("ioctl2"); + close(sock); close(tun_fd); return -1; } + close(sock); + // Setup the IP address sock = socket(AF_INET, SOCK_DGRAM, 0); ifr.ifr_addr.sa_family = AF_INET; @@ -636,6 +640,7 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFADDR, &ifr)) { perror("ioctl"); + close(sock); close(tun_fd); return -1; } @@ -644,9 +649,12 @@ int setup_if_addr(char *ip_addr) if(0 > ioctl(sock, SIOCSIFNETMASK, &ifr)) { perror("ioctl"); + close(sock); close(tun_fd); return -1; } + close(sock); + return(tun_fd); }