fix more coverity issues

This commit is contained in:
Andre Puschmann 2018-01-31 12:35:46 +01:00
parent ed46abbad0
commit d500bdbc24
4 changed files with 13 additions and 4 deletions

View File

@ -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]);

View File

@ -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_id<MAX_PENDING_RARS) {
while(pending_rars[ra_id].temp_crnti && ra_id<MAX_PENDING_RARS-1) {
ra_id++;
}
if (ra_id == MAX_PENDING_RARS) {

View File

@ -256,7 +256,7 @@ void ue::push_pdu(uint32_t tti, uint32_t len)
bool ue::process_ce(srslte::sch_subh *subh) {
uint32_t buff_size[4] = {0, 0, 0, 0};
float phr = 0;
int idx = 0;
uint32_t idx = 0;
uint16_t old_rnti = 0;
bool is_bsr = false;
switch(subh->ce_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;i<lc_groups[idx].size();i++) {
sched->ul_bsr(rnti, lc_groups[idx][i], buff_size[idx]);
}

View File

@ -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);
}