Skip to content

Commit

Permalink
Fix integration test bugs reported by Coverity. (#167)
Browse files Browse the repository at this point in the history
  • Loading branch information
gordonwang0 authored and huguesBouvier committed Apr 23, 2018
1 parent 025e714 commit 4ff32f7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/aws_iot_mqtt_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ IoT_Error_t aws_iot_mqtt_free(AWS_IoT_Client *pClient)
{
rc = aws_iot_thread_mutex_destroy(&(pClient->clientData.tls_write_mutex));
}else{
(void)aws_iot_thread_mutex_destroy(&(pClient->clientData.tls_read_mutex));
(void)aws_iot_thread_mutex_destroy(&(pClient->clientData.tls_write_mutex));
}
#endif
}
Expand Down
2 changes: 1 addition & 1 deletion src/aws_iot_shadow.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ IoT_Error_t aws_iot_shadow_free(AWS_IoT_Client *pClient)
}

IoT_Error_t aws_iot_shadow_init(AWS_IoT_Client *pClient, ShadowInitParameters_t *pParams) {
IoT_Client_Init_Params mqttInitParams;
IoT_Client_Init_Params mqttInitParams = IoT_Client_Init_Params_initializer;
IoT_Error_t rc;

FUNC_ENTRY;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ static void *aws_iot_mqtt_tests_sub_unsub_thread_runner(void *ptr) {
IOT_ERROR("Unsubscribe Returned : %d ", rc);
}
}

return NULL;
}

int aws_iot_mqtt_tests_multi_threading_validation() {
Expand All @@ -192,7 +194,7 @@ int aws_iot_mqtt_tests_multi_threading_validation() {
char root_CA[PATH_MAX + 1];

char clientId[50];
IoT_Client_Init_Params initParams;
IoT_Client_Init_Params initParams = IoT_Client_Init_Params_initializer;
IoT_Client_Connect_Params connectParams;
int threadId[MAX_PUB_THREAD_COUNT];
int pubThreadReturn[MAX_PUB_THREAD_COUNT];
Expand All @@ -201,7 +203,7 @@ int aws_iot_mqtt_tests_multi_threading_validation() {
int finishedThreadCount = 0;
IoT_Error_t rc = SUCCESS;
int i, rxMsgCount = 0, j = 0;
struct timeval connectTime, subscribeTopic;
struct timeval subscribeTopic;
unsigned int connectCounter = 0;
int test_result = 0;
ThreadData threadData[MAX_PUB_THREAD_COUNT];
Expand Down Expand Up @@ -262,7 +264,7 @@ int aws_iot_mqtt_tests_multi_threading_validation() {
} while(SUCCESS != rc && connectCounter < CONNECT_MAX_ATTEMPT_COUNT);

if(SUCCESS == rc) {
printf("\n## Connect Success. Time sec: %d, usec: %d\n", connectTime.tv_sec, connectTime.tv_usec);
printf("\n## Connect Success.\n");
} else {
IOT_ERROR("## Connect Failed. error code %d\n", rc);
return -1;
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/src/aws_iot_test_auto_reconnect.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void aws_iot_mqtt_tests_block_tls_connect(AWS_IoT_Client *pClient) {
/**
* Always ensure this function is called after block_tls_connect
*/
int aws_iot_mqtt_tests_unblock_tls_connect(AWS_IoT_Client *pClient) {
void aws_iot_mqtt_tests_unblock_tls_connect(AWS_IoT_Client *pClient) {
pClient->networkStack.tlsConnectParams.pRootCALocation = savedLocation;
}

Expand All @@ -62,6 +62,8 @@ void *aws_iot_mqtt_tests_yield_with_rc(void *ptr) {
yieldRC = rc;
}
}

return NULL;
}

unsigned int disconnectedCounter = 0;
Expand Down Expand Up @@ -91,7 +93,7 @@ int aws_iot_mqtt_tests_auto_reconnect() {
snprintf(clientId, 50, "%s_%d", INTEGRATION_TEST_CLIENT_ID, rand() % 10000);

printf(" Root CA Path : %s\n clientCRT : %s\n clientKey : %s\n", root_CA, clientCRT, clientKey);
IoT_Client_Init_Params initParams;
IoT_Client_Init_Params initParams = IoT_Client_Init_Params_initializer;
initParams.pHostURL = AWS_IOT_MQTT_HOST;
initParams.port = AWS_IOT_MQTT_PORT;
initParams.pRootCALocation = root_CA;
Expand Down

0 comments on commit 4ff32f7

Please sign in to comment.