From df2997d9b762d705d5f7add338e460686c9bd88f Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Wed, 26 May 2021 15:44:24 +0200 Subject: [PATCH] Eliminate compiler warnings in tests --- src/test/check_getdns_cancel_callback.h | 8 ++++---- src/test/check_getdns_common.c | 10 +++++----- src/test/check_getdns_convert_alabel_to_ulabel.h | 2 +- src/test/check_getdns_convert_ulabel_to_alabel.h | 2 +- src/test/check_getdns_dict_get_bindata.h | 2 +- src/test/check_getdns_dict_get_names.h | 2 +- src/test/check_getdns_dict_set_bindata.h | 6 +++--- src/test/check_getdns_list_get_length.h | 4 ++-- 8 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/test/check_getdns_cancel_callback.h b/src/test/check_getdns_cancel_callback.h index facf31bc..c6cad3c7 100644 --- a/src/test/check_getdns_cancel_callback.h +++ b/src/test/check_getdns_cancel_callback.h @@ -466,23 +466,23 @@ callback_canceled++; ck_assert_msg(transaction_id % 2, "Only callbacks with odd transaction_ids were canceled, this one is even: %d", - transaction_id); + (int)transaction_id); } else if(callback_type == GETDNS_CALLBACK_COMPLETE) { callback_completed++; ck_assert_msg((transaction_id % 2) == 0, "One callbacks with even transaction_ids should complete, this one is odd: %d", - transaction_id); + (int)transaction_id); } else { if(transaction_id % 2) ck_abort_msg("callback_type should == GETDNS_CALLBACK_CANCEL for odd transaction_id (%d), got: %d", - transaction_id, callback_type); + (int)transaction_id, (int)callback_type); else ck_abort_msg("callback_type should == GETDNS_CALLBACK_COMPLETE for even transaction_id (%d), got %d", - transaction_id, callback_type); + (int)transaction_id, (int)callback_type); } } diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 723f7f81..b43f5d8b 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -196,7 +196,7 @@ void assert_nodata(struct extracted_response *ex_response) ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); - ck_assert_msg(length == 0, "Expected \"answer\" length == 0, got %d", length); + ck_assert_msg(length == 0, "Expected \"answer\" length == 0, got %d", (int)length); ASSERT_RC(ex_response->status, GETDNS_RESPSTATUS_NO_NAME, "Unexpected value for \"status\""); } @@ -222,7 +222,7 @@ void assert_address_in_answer(struct extracted_response *ex_response, int a, int ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); - ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length); + ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", (int)ancount, (int)length); for(i = 0; i < length; i++) { @@ -257,7 +257,7 @@ void assert_address_in_just_address_answers(struct extracted_response *ex_respon GETDNS_RETURN_GOOD, "Failed to extract \"just_address_answers\" length"); if (length == 0) resp_str = getdns_pretty_print_dict(ex_response->response); - ck_assert_msg(length > 0, "Expected \"just_address_answers\" length > 0, got %d\n%s", length, resp_str); + ck_assert_msg(length > 0, "Expected \"just_address_answers\" length > 0, got %d\n%s", (int)length, resp_str); if (length == 0) free(resp_str); } @@ -294,7 +294,7 @@ void assert_soa_in_authority(struct extracted_response *ex_response) ASSERT_RC(getdns_list_get_length(ex_response->authority, &length), GETDNS_RETURN_GOOD, "Failed to extract \"authority\" length"); - ck_assert_msg(length == nscount, "Expected \"authority\" length == nscount: %d, got %d", nscount, length); + ck_assert_msg(length == nscount, "Expected \"authority\" length == nscount: %d, got %d", (int)nscount, (int)length); for(i = 0; i < length; i++) { @@ -328,7 +328,7 @@ void assert_ptr_in_answer(struct extracted_response *ex_response) ASSERT_RC(getdns_list_get_length(ex_response->answer, &length), GETDNS_RETURN_GOOD, "Failed to extract \"answer\" length"); - ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", ancount, length); + ck_assert_msg(length == ancount, "Expected \"answer\" length == ancount: %d, got %d", (int)ancount, (int)length); for(i = 0; i < length; i++) { diff --git a/src/test/check_getdns_convert_alabel_to_ulabel.h b/src/test/check_getdns_convert_alabel_to_ulabel.h index b58ef41e..37530888 100644 --- a/src/test/check_getdns_convert_alabel_to_ulabel.h +++ b/src/test/check_getdns_convert_alabel_to_ulabel.h @@ -44,7 +44,7 @@ char *alabel = NULL; ck_assert_msg( getdns_convert_alabel_to_ulabel( alabel ) == 0, - "Was not expecting %d from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); + "Was not expecting %p from getdns_convert_alabel_to_ulabel()", getdns_convert_alabel_to_ulabel( alabel ) ); } END_TEST diff --git a/src/test/check_getdns_convert_ulabel_to_alabel.h b/src/test/check_getdns_convert_ulabel_to_alabel.h index 3af671f8..d20c8c84 100644 --- a/src/test/check_getdns_convert_ulabel_to_alabel.h +++ b/src/test/check_getdns_convert_ulabel_to_alabel.h @@ -45,7 +45,7 @@ ck_assert_msg(( getdns_convert_ulabel_to_alabel( ulabel ) == 0 ), - "Was not expecting %d from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); + "Was not expecting %p from getdns_convert_ulabel_to_alabel()", getdns_convert_ulabel_to_alabel( ulabel ) ); } END_TEST diff --git a/src/test/check_getdns_dict_get_bindata.h b/src/test/check_getdns_dict_get_bindata.h index 60366983..874d124d 100644 --- a/src/test/check_getdns_dict_get_bindata.h +++ b/src/test/check_getdns_dict_get_bindata.h @@ -161,7 +161,7 @@ GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()"); ck_assert_msg(answer->size == bindata.size, "Expected bindata size == %d, got: %d", - bindata.size, answer->size); + (int)bindata.size, (int)answer->size); ck_assert_msg(strcmp((char *)answer->data, (char *)bindata.data) == 0, "Expected bindata data to be \"%s\", got: \"%s\"", (char *)bindata.data, (char *)answer->data); diff --git a/src/test/check_getdns_dict_get_names.h b/src/test/check_getdns_dict_get_names.h index 0881ad0f..4275d4fb 100644 --- a/src/test/check_getdns_dict_get_names.h +++ b/src/test/check_getdns_dict_get_names.h @@ -98,7 +98,7 @@ ASSERT_RC(getdns_list_get_length(answer, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); - ck_assert_msg(length == 3, "Expected length == 3, got %d", length); + ck_assert_msg(length == 3, "Expected length == 3, got %d", (int)length); for(i = 0; i < length; i++) { diff --git a/src/test/check_getdns_dict_set_bindata.h b/src/test/check_getdns_dict_set_bindata.h index ac51c3a5..c73030cf 100644 --- a/src/test/check_getdns_dict_set_bindata.h +++ b/src/test/check_getdns_dict_set_bindata.h @@ -112,9 +112,9 @@ ASSERT_RC(getdns_dict_get_bindata(this_dict, "bindata", &retrieved_bindata), GETDNS_RETURN_GOOD, "Return code from getdns_dict_get_bindata()"); - ck_assert_msg(retrieved_bindata->size, second_bindata.size, + ck_assert_msg(retrieved_bindata->size == second_bindata.size, "Expected retrieved bindata size == %d, got: %d", - second_bindata.size, retrieved_bindata->size); + (int)second_bindata.size, (int)retrieved_bindata->size); ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)second_bindata.data) == 0, "Expected retrieved bindata to be \"%s\", got: \"%s\"", @@ -152,7 +152,7 @@ ck_assert_msg(retrieved_bindata->size == bindata.size, "Expected retrieved bindata size == %d, got: %d", - bindata.size, retrieved_bindata->size); + (int)bindata.size, (int)retrieved_bindata->size); ck_assert_msg(strcmp((char *)retrieved_bindata->data, (char *)bindata.data) == 0, "Expected bindata data to be \"%s\", got: \"%s\"", diff --git a/src/test/check_getdns_list_get_length.h b/src/test/check_getdns_list_get_length.h index 3ccb8551..e1bceb68 100644 --- a/src/test/check_getdns_list_get_length.h +++ b/src/test/check_getdns_list_get_length.h @@ -89,7 +89,7 @@ ASSERT_RC(getdns_list_get_length(list, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); - ck_assert_msg(length == 3, "Expected length == 3, got %d", length); + ck_assert_msg(length == 3, "Expected length == 3, got %d", (int)length); LIST_DESTROY(list); } @@ -110,7 +110,7 @@ ASSERT_RC(getdns_list_get_length(list, &length), GETDNS_RETURN_GOOD, "Return code from getdns_list_get_length()"); - ck_assert_msg(length == 0, "Expected length == 3, got %d", length); + ck_assert_msg(length == 0, "Expected length == 3, got %d", (int)length); LIST_DESTROY(list); }