Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix integration test bugs reported by Coverity. #167

Merged
merged 1 commit into from
Apr 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why removing those?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see connectTime used anywhere? It's declared on line 206, but not used anywhere until it's printed here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh! that's correct, good finding

} 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