From a5748be5fbdf4ff034217d01203b308b9ef27e08 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 14:39:38 +0100 Subject: [PATCH] Unit test fixes for CFLAGS=-Wextra --- src/test/check_getdns.c | 2 +- src/test/check_getdns_cancel_callback.h | 3 +++ src/test/check_getdns_common.c | 4 +++- src/test/check_getdns_context_destroy.h | 1 + src/test/check_getdns_context_set_timeout.c | 1 + src/test/check_getdns_dict_get_names.h | 2 +- src/test/check_getdns_libev.c | 1 + src/test/check_getdns_libevent.c | 1 + src/test/check_getdns_libuv.c | 1 + src/test/check_getdns_selectloop.c | 2 ++ src/test/check_getdns_transport.c | 2 ++ src/test/tests_dict.c | 4 ++-- src/test/tests_list.c | 2 +- src/test/tests_stub_async.c | 2 ++ 14 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/test/check_getdns.c b/src/test/check_getdns.c index e5974d1d..f2dff1fa 100644 --- a/src/test/check_getdns.c +++ b/src/test/check_getdns.c @@ -75,7 +75,7 @@ int -main (int argc, char** argv) +main () { int number_failed; SRunner *sr ; diff --git a/src/test/check_getdns_cancel_callback.h b/src/test/check_getdns_cancel_callback.h index 7ad31b46..08331771 100644 --- a/src/test/check_getdns_cancel_callback.h +++ b/src/test/check_getdns_cancel_callback.h @@ -451,6 +451,8 @@ void *userarg, getdns_transaction_t transaction_id) { + (void)context; (void)response; (void)userarg; + callback_called++; if(callback_type == GETDNS_CALLBACK_CANCEL) @@ -483,6 +485,7 @@ */ void verify_getdns_cancel_callback(struct extracted_response *ex_response) { + (void)ex_response; /* * increment callback_called global to prove callback was called. */ diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 79f177a9..87f0727e 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -320,6 +320,7 @@ void destroy_callbackfn(struct getdns_context *context, void *userarg, getdns_transaction_t transaction_id) { int* flag = (int*)userarg; + (void)callback_type; (void)transaction_id; *flag = 1; getdns_dict_destroy(response); getdns_context_destroy(context); @@ -339,6 +340,7 @@ void callbackfn(struct getdns_context *context, { typedef void (*fn_ptr)(struct extracted_response *ex_response); fn_ptr fn = userarg; + (void)context; (void)transaction_id; /* * If userarg is NULL, either a negative test case @@ -378,7 +380,7 @@ void callbackfn(struct getdns_context *context, void update_callbackfn(struct getdns_context *context, getdns_context_code_t changed_item) { - + (void)context; ck_assert_msg(changed_item == expected_changed_item, "Expected changed_item == %d, got %d", changed_item, expected_changed_item); diff --git a/src/test/check_getdns_context_destroy.h b/src/test/check_getdns_context_destroy.h index 52b28456..381da9f8 100644 --- a/src/test/check_getdns_context_destroy.h +++ b/src/test/check_getdns_context_destroy.h @@ -267,6 +267,7 @@ void verify_getdns_context_destroy(struct extracted_response *ex_response) { + (void)ex_response; /* * Sleep for a second to make getdns_context_destroy() wait. */ diff --git a/src/test/check_getdns_context_set_timeout.c b/src/test/check_getdns_context_set_timeout.c index f588445a..26d25aa5 100644 --- a/src/test/check_getdns_context_set_timeout.c +++ b/src/test/check_getdns_context_set_timeout.c @@ -243,6 +243,7 @@ void timeout_3_cb(struct getdns_context *context, getdns_callback_type_t callback_type, struct getdns_dict * response, void *userarg, getdns_transaction_t transaction_id) { + (void)response; (void)transaction_id; timeout_thread_data *tdata = (timeout_thread_data*)userarg; tdata->num_callbacks++; if (callback_type == GETDNS_CALLBACK_TIMEOUT) { diff --git a/src/test/check_getdns_dict_get_names.h b/src/test/check_getdns_dict_get_names.h index 46f06f0a..0881ad0f 100644 --- a/src/test/check_getdns_dict_get_names.h +++ b/src/test/check_getdns_dict_get_names.h @@ -79,7 +79,7 @@ struct getdns_list *answer = NULL; char *keys[3] = { "ten", "eleven", "twelve" }; uint32_t values[3] = { 10, 11, 12 }; - int i; + size_t i; size_t length; struct getdns_bindata *key = NULL; char string_buffer[20] = ""; diff --git a/src/test/check_getdns_libev.c b/src/test/check_getdns_libev.c index 9120cf5a..5523f126 100644 --- a/src/test/check_getdns_libev.c +++ b/src/test/check_getdns_libev.c @@ -46,6 +46,7 @@ void run_event_loop_impl(struct getdns_context* context, void* eventloop) { struct ev_loop* loop = (struct ev_loop*) eventloop; + (void)context; ev_run(loop, 0); } diff --git a/src/test/check_getdns_libevent.c b/src/test/check_getdns_libevent.c index 304f42ef..e9316b6f 100644 --- a/src/test/check_getdns_libevent.c +++ b/src/test/check_getdns_libevent.c @@ -42,6 +42,7 @@ void run_event_loop_impl(struct getdns_context* context, void* eventloop) { struct event_base* base = (struct event_base*) eventloop; + (void)context; event_base_dispatch(base); } diff --git a/src/test/check_getdns_libuv.c b/src/test/check_getdns_libuv.c index 3d830445..b7d50e72 100644 --- a/src/test/check_getdns_libuv.c +++ b/src/test/check_getdns_libuv.c @@ -42,6 +42,7 @@ void run_event_loop_impl(struct getdns_context* context, void* eventloop) { uv_loop_t* loop = (uv_loop_t*) eventloop; + (void)context; uv_run(loop, UV_RUN_DEFAULT); } diff --git a/src/test/check_getdns_selectloop.c b/src/test/check_getdns_selectloop.c index b80f1ffd..c315b30c 100644 --- a/src/test/check_getdns_selectloop.c +++ b/src/test/check_getdns_selectloop.c @@ -37,9 +37,11 @@ #include "getdns/getdns_extra.h" void run_event_loop_impl(struct getdns_context* context, void* eventloop) { + (void)eventloop; getdns_context_run(context); } void* create_eventloop_impl(struct getdns_context* context) { + (void)context; return NULL; } diff --git a/src/test/check_getdns_transport.c b/src/test/check_getdns_transport.c index 7d97c27c..4b93fdd1 100644 --- a/src/test/check_getdns_transport.c +++ b/src/test/check_getdns_transport.c @@ -193,6 +193,8 @@ void transport_cb(struct getdns_context *context, struct getdns_dict * response, void *userarg, getdns_transaction_t transaction_id) { /* Don't really care about the answer*/ + (void)context; (void)callback_type; (void)response; + (void)userarg; (void)transaction_id; return; } diff --git a/src/test/tests_dict.c b/src/test/tests_dict.c index 4be804f5..963ba7b4 100644 --- a/src/test/tests_dict.c +++ b/src/test/tests_dict.c @@ -214,7 +214,7 @@ tst_getnames(void) size_t index; size_t llen; uint32_t ansint; - int i; + size_t i; getdns_return_t result; getdns_data_type dtype; struct getdns_dict *dict = NULL; @@ -508,7 +508,7 @@ tst_create(void) * runs unit tests against list management routines */ int -main(int argc, char *argv[]) +main() { tstmsg_prog_begin("tests_dict"); diff --git a/src/test/tests_list.c b/src/test/tests_list.c index c8a68bd8..ab9a98cf 100644 --- a/src/test/tests_list.c +++ b/src/test/tests_list.c @@ -404,7 +404,7 @@ tst_create(void) * runs unit tests against list management routines */ int -main(int argc, char *argv[]) +main() { tstmsg_prog_begin("tests_list"); diff --git a/src/test/tests_stub_async.c b/src/test/tests_stub_async.c index a5b3c995..79a8029c 100644 --- a/src/test/tests_stub_async.c +++ b/src/test/tests_stub_async.c @@ -57,6 +57,8 @@ this_callbackfn(struct getdns_context *this_context, struct getdns_dict *this_response, void *this_userarg, getdns_transaction_t this_transaction_id) { + (void)this_context; (void)this_userarg; + if (this_callback_type == GETDNS_CALLBACK_COMPLETE) { /* This is a callback with data */ char *res = getdns_pretty_print_dict(this_response); fprintf(stdout, "%s\n", res);