Fixes to Coverity defects:

72643
72645
72655
72656
72657
72658
72664
72698
72712
This commit is contained in:
Markus Makela
2014-11-12 19:02:37 +02:00
parent b5445bdf63
commit fc5c3943e8
6 changed files with 89 additions and 34 deletions

View File

@ -269,7 +269,17 @@ MAXKEYS key;
errno,
strerror(errno))));
}
chmod(secret_file, S_IRUSR);
if( chmod(secret_file, S_IRUSR) < 0)
{
LOGIF(LE, (skygw_log_write_flush(
LOGFILE_ERROR,
"Error : failed to change the permissions of the"
"secret file [%s]. Error %d, %s.",
secret_file,
errno,
strerror(errno))));
}
return 0;
}

View File

@ -30,7 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <poll.h>
#include <dcb.h>
@ -44,6 +44,7 @@ test1()
{
DCB *dcb;
int result;
int eno = 0;
/* Poll tests */
ss_dfprintf(stderr,
@ -51,20 +52,32 @@ int result;
poll_init();
ss_dfprintf(stderr, "\t..done\nAdd a DCB");
dcb = dcb_alloc(DCB_ROLE_SERVICE_LISTENER);
if(dcb == NULL){
ss_dfprintf(stderr, "\nError on function call: dcb_alloc() returned NULL.\n");
return 1;
}
dcb->fd = socket(AF_UNIX, SOCK_STREAM, 0);
if(poll_add_dcb(dcb) != 0){
ss_dfprintf(stderr, "Error on function call: poll_add_dcb\n");
if(dcb->fd < 0){
ss_dfprintf(stderr, "\nError on function call: socket() returned %d: %s\n",errno,strerror(errno));
return 1;
}
if(poll_remove_dcb(dcb) != 0){
ss_dfprintf(stderr, "Error on function call: poll_remove_dcb\n");
if((eno = poll_add_dcb(dcb)) != 0){
ss_dfprintf(stderr, "\nError on function call: poll_add_dcb() returned %d.\n",eno);
return 1;
}
if(poll_add_dcb(dcb) != 0){
ss_dfprintf(stderr, "Error on function call: poll_add_dcb\n");
if((eno = poll_remove_dcb(dcb)) != 0){
ss_dfprintf(stderr, "\nError on function call: poll_remove_dcb() returned %d.\n",eno);
return 1;
}
if((eno = poll_add_dcb(dcb)) != 0){
ss_dfprintf(stderr, "\nError on function call: poll_add_dcb() returned %d.\n",eno);
return 1;
}

View File

@ -225,7 +225,9 @@ int gw_getsockerrno(
goto return_eno;
}
getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&eno, &elen);
if(getsockopt(fd, SOL_SOCKET, SO_ERROR, (void *)&eno, &elen) != 0){
eno = 0;
}
return_eno:
return eno;