mirror of
https://github.com/outbackdingo/parodus.git
synced 2026-01-27 10:20:04 +00:00
Fixed few more coverity defects
This commit is contained in:
@@ -56,7 +56,7 @@ char *get_global_reconnect_reason()
|
||||
void test_getWebpaConveyHeader()
|
||||
{
|
||||
ParodusCfg cfg;
|
||||
|
||||
memset(&cfg, 0, sizeof(ParodusCfg));
|
||||
parStrncpy(cfg.hw_model, "TG1682", sizeof(cfg.hw_model));
|
||||
parStrncpy(cfg.hw_serial_number, "Fer23u948590", sizeof(cfg.hw_serial_number));
|
||||
parStrncpy(cfg.hw_manufacturer , "ARRISGroup,Inc.", sizeof(cfg.hw_manufacturer));
|
||||
|
||||
@@ -87,13 +87,23 @@ static void *client_rcv_task()
|
||||
int byte =0;
|
||||
int rv1=0;
|
||||
int t=25000;
|
||||
int rc = -1;
|
||||
int bind;
|
||||
wrp_msg_t *msg1;
|
||||
|
||||
int sock1 = nn_socket (AF_SP, NN_PULL);
|
||||
nn_bind(sock1, TEST_CLIENT1_URL);
|
||||
bind = nn_bind(sock1, TEST_CLIENT1_URL);
|
||||
if(bind < 0)
|
||||
{
|
||||
ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
void *buf = NULL;
|
||||
nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
if(rc < 0)
|
||||
{
|
||||
ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
ParodusPrint("Client 1 waiting for acknowledgement \n");
|
||||
byte = nn_recv(sock1, &buf, NN_MSG, 0);
|
||||
@@ -119,13 +129,23 @@ static void *client2_rcv_task()
|
||||
int byte =0;
|
||||
int rv1=0;
|
||||
int t=25000;
|
||||
int rc = -1;
|
||||
int bind;
|
||||
wrp_msg_t *msg1;
|
||||
|
||||
int sock1 = nn_socket (AF_SP, NN_PULL);
|
||||
nn_bind(sock1, TEST_CLIENT2_URL);
|
||||
bind = nn_bind(sock1, TEST_CLIENT2_URL);
|
||||
if(bind < 0)
|
||||
{
|
||||
ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
void *buf = NULL;
|
||||
nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
if(rc < 0)
|
||||
{
|
||||
ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
ParodusPrint("Client 2 waiting for acknowledgement \n");
|
||||
byte = nn_recv(sock1, &buf, NN_MSG, 0);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
UpStreamMsg *UpStreamMsgQ;
|
||||
ParodusMsg *ParodusMsgQ;
|
||||
extern bool close_retry;
|
||||
extern pthread_mutex_t close_mut;
|
||||
extern volatile unsigned int heartBeatTimer;
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Mocks */
|
||||
@@ -160,7 +161,9 @@ void test_createSocketConnection()
|
||||
ParodusCfg cfg;
|
||||
memset(&cfg,0,sizeof(ParodusCfg));
|
||||
|
||||
pthread_mutex_lock (&close_mut);
|
||||
close_retry = false;
|
||||
pthread_mutex_unlock (&close_mut);
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
|
||||
will_return(nopoll_ctx_new, (intptr_t)&ctx);
|
||||
@@ -195,7 +198,9 @@ void test_createSocketConnection1()
|
||||
noPollCtx *ctx;
|
||||
ParodusCfg cfg;
|
||||
memset(&cfg,0, sizeof(ParodusCfg));
|
||||
pthread_mutex_lock (&close_mut);
|
||||
close_retry = true;
|
||||
pthread_mutex_unlock (&close_mut);
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
|
||||
will_return(nopoll_ctx_new, (intptr_t)&ctx);
|
||||
@@ -242,7 +247,9 @@ void test_createSocketConnection2()
|
||||
parStrncpy(cfg.webpa_uuid , "1234567-345456546", sizeof(cfg.webpa_uuid));
|
||||
cfg.webpa_ping_timeout = 1;
|
||||
|
||||
pthread_mutex_lock (&close_mut);
|
||||
close_retry = false;
|
||||
pthread_mutex_unlock (&close_mut);
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
|
||||
will_return(nopoll_ctx_new, (intptr_t)&ctx);
|
||||
@@ -279,7 +286,9 @@ void test_createSocketConnection2()
|
||||
|
||||
void err_createSocketConnection()
|
||||
{
|
||||
pthread_mutex_lock (&close_mut);
|
||||
close_retry = true;
|
||||
pthread_mutex_unlock (&close_mut);
|
||||
heartBeatTimer = 0;
|
||||
expect_function_call(nopoll_thread_handlers);
|
||||
|
||||
|
||||
@@ -54,9 +54,7 @@ void* a(void *in)
|
||||
|
||||
lockMutex(data->mutex);
|
||||
data->number++;
|
||||
sleep(1);
|
||||
data->number++;
|
||||
sleep(1);
|
||||
data->number++;
|
||||
unlockMutex(data->mutex);
|
||||
|
||||
@@ -69,9 +67,7 @@ void* b(void *in)
|
||||
|
||||
lockMutex(data->mutex);
|
||||
data->number+=10;
|
||||
sleep(1);
|
||||
data->number+=10;
|
||||
sleep(1);
|
||||
data->number+=10;
|
||||
unlockMutex(data->mutex);
|
||||
|
||||
@@ -108,6 +104,8 @@ void err_mutex()
|
||||
|
||||
will_return(pthread_mutex_init, -1);
|
||||
mutex = createMutex();
|
||||
destroyMutex(mutex);
|
||||
|
||||
}
|
||||
|
||||
void err_mutexNull()
|
||||
|
||||
@@ -129,7 +129,8 @@ void test_validate_partner_id_for_event()
|
||||
|
||||
partners_t *list = NULL;
|
||||
int ret = validate_partner_id(msg, &list);
|
||||
assert_int_equal(ret, 1);
|
||||
assert_int_equal(ret, 1);
|
||||
free(list);
|
||||
free(msg);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,13 +77,23 @@ static void *client_rcv_task()
|
||||
int byte =0;
|
||||
int rv1=0;
|
||||
int t=25000;
|
||||
int rc = -1;
|
||||
int bind;
|
||||
wrp_msg_t *msg1;
|
||||
|
||||
sock1 = nn_socket (AF_SP, NN_PULL);
|
||||
nn_bind(sock1, TEST_SERVICE_URL);
|
||||
bind = nn_bind(sock1, TEST_SERVICE_URL);
|
||||
if(bind < 0)
|
||||
{
|
||||
ParodusError("Unable to bind socket (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
void *buf = NULL;
|
||||
nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
rc = nn_setsockopt(sock1, NN_SOL_SOCKET, NN_RCVTIMEO, &t, sizeof(t));
|
||||
if(rc < 0)
|
||||
{
|
||||
ParodusError ("Unable to set socket timeout (errno=%d, %s)\n",errno, strerror(errno));
|
||||
}
|
||||
|
||||
ParodusPrint("Client 1 waiting for acknowledgement \n");
|
||||
byte = nn_recv(sock1, &buf, NN_MSG, 0);
|
||||
|
||||
Reference in New Issue
Block a user