Fix pedantic warnings in unit tests

This commit is contained in:
Willem Toorop 2016-12-08 22:33:10 +01:00
parent fbb4eb717a
commit 55cdd8fed3
8 changed files with 55 additions and 26 deletions

View File

@ -149,6 +149,7 @@
* rcode = 0
*/
void verify_getdns_address_6(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_address_6 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -157,7 +158,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "google.com", NULL,
verify_getdns_address_6, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@ -183,6 +184,7 @@
* ancount = 1 (number of records in ANSWER section)
*/
void verify_getdns_address_7(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_address_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -191,7 +193,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "localhost", NULL,
verify_getdns_address_7, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@ -213,6 +215,7 @@
* rcode = 3 (NXDOMAIN)
*/
void verify_getdns_address_8(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_address_8 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -222,7 +225,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "hostnamedoesntexist", NULL,
verify_getdns_address_8, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;

View File

@ -55,6 +55,7 @@
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
*/
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_cancel_callback };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@ -65,7 +66,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
verify_getdns_cancel_callback, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -86,6 +87,7 @@
* expect: GETDNS_RETURN_UNKNOWN_TRANSACTION
*/
void verify_getdns_cancel_callback(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_cancel_callback };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@ -96,7 +98,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
verify_getdns_cancel_callback, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -133,7 +135,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
getdns_transaction_t transaction_id_array[10] = {};
getdns_transaction_t transaction_id_array[10]
= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@ -212,7 +215,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
getdns_transaction_t transaction_id_array[10] = {};
getdns_transaction_t transaction_id_array[10]
= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@ -295,7 +299,8 @@
struct getdns_bindata address_data = { 4, (void *)"\x08\x08\x08\x08" };
struct getdns_dict *address = NULL;
getdns_transaction_t transaction_id = 0;
getdns_transaction_t transaction_id_array[10] = {};
getdns_transaction_t transaction_id_array[10]
= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;
@ -381,7 +386,8 @@
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
getdns_transaction_t transaction_id_array[10] = {};
getdns_transaction_t transaction_id_array[10]
= {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int i;
int odd = 0;
int even = 0;

View File

@ -339,7 +339,7 @@ void callbackfn(struct getdns_context *context,
getdns_transaction_t transaction_id)
{
typedef void (*fn_ptr)(struct extracted_response *ex_response);
fn_ptr fn = userarg;
fn_ptr fn = ((fn_cont *)userarg)->fn;
(void)context; (void)transaction_id;
/*

View File

@ -211,6 +211,10 @@
struct getdns_dict *response,
void *userarg,
getdns_transaction_t transaction_id);
typedef struct fn_cont {
void (*fn)(struct extracted_response *ex_response);
} fn_cont;
/*
* callbackfn is the callback function given to all
* asynchronous query tests. It is expected to only

View File

@ -68,6 +68,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@ -78,7 +79,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
verify_getdns_context_destroy, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -95,6 +96,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@ -105,7 +107,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_address(context, "google.com", NULL,
verify_getdns_context_destroy, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@ -122,6 +124,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@ -141,7 +144,7 @@
GETDNS_RETURN_GOOD, "Return code from getdns_dict_set_bindata");
ASSERT_RC(getdns_hostname(context, address, NULL,
verify_getdns_context_destroy, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_address()");
RUN_EVENT_LOOP;
@ -159,6 +162,7 @@
* expect: callback should be called before getdns_context_destroy() returns
*/
void verify_getdns_context_destroy(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_context_destroy };
struct getdns_context *context = NULL;
void* eventloop = NULL;
getdns_transaction_t transaction_id = 0;
@ -169,7 +173,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_service(context, "google.com", NULL,
verify_getdns_context_destroy, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
RUN_EVENT_LOOP;

View File

@ -151,6 +151,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_6(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_6 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -159,7 +160,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", 0, NULL,
verify_getdns_general_6, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -184,6 +185,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_7(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -192,7 +194,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", 65279, NULL,
verify_getdns_general_7, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -218,6 +220,7 @@
* and equals number of A records ("type": 1) in "answer" list
*/
void verify_getdns_general_8(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_8 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -226,7 +229,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
verify_getdns_general_8, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -252,6 +255,7 @@
* and equals number of AAAA records ("type": 28) in "answer" list
*/
void verify_getdns_general_9(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_9 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -260,7 +264,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_AAAA, NULL,
verify_getdns_general_9, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -287,6 +291,7 @@
* and SOA record ("type": 6) present in "authority" list
*/
void verify_getdns_general_10(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_10 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -296,7 +301,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, name, GETDNS_RRTYPE_TXT, NULL,
verify_getdns_general_10, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -322,6 +327,7 @@
* ancount = 0 (number of records in ANSWER section)
*/
void verify_getdns_general_11(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_11 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -330,7 +336,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "willem.getdnsapi.net", GETDNS_RRTYPE_MX, NULL,
verify_getdns_general_11, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;
@ -356,6 +362,7 @@
* and equals number of A records ("type": 1) in "answer" list
*/
void verify_getdns_general_12(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_general_12 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -364,7 +371,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_general(context, "google.com", GETDNS_RRTYPE_A, NULL,
verify_getdns_general_12, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_general()");
RUN_EVENT_LOOP;

View File

@ -315,6 +315,7 @@
* expect: response with correct hostname
*/
void verify_getdns_hostname_10(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_hostname_10 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@ -333,7 +334,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
verify_getdns_hostname_10, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@ -356,6 +357,7 @@
* expect: response with no hostname
*/
void verify_getdns_hostname_11(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_hostname_11 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv4" };
@ -374,7 +376,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
verify_getdns_hostname_11, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@ -398,6 +400,7 @@
* expect: response with correct hostname
*/
void verify_getdns_hostname_12(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_hostname_12 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
@ -419,7 +422,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
verify_getdns_hostname_12, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;
@ -442,6 +445,7 @@
* expect: response with no hostname
*/
void verify_getdns_hostname_13(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_hostname_13 };
struct getdns_context *context = NULL;
struct getdns_dict *address = NULL;
struct getdns_bindata address_type = { 5, (void *)"IPv6" };
@ -460,7 +464,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_hostname(context, address, NULL,
verify_getdns_hostname_13, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_hostname()");
RUN_EVENT_LOOP;

View File

@ -148,6 +148,7 @@
* expect: NXDOMAIN response (with SOA record)
*/
void verify_getdns_service_7(struct extracted_response *ex_response);
fn_cont fn_ref = { verify_getdns_service_7 };
struct getdns_context *context = NULL; \
void* eventloop = NULL; \
getdns_transaction_t transaction_id = 0;
@ -157,7 +158,7 @@
EVENT_BASE_CREATE;
ASSERT_RC(getdns_service(context, "nitinsinghit.com", NULL,
verify_getdns_address_8, &transaction_id, callbackfn),
&fn_ref, &transaction_id, callbackfn),
GETDNS_RETURN_GOOD, "Return code from getdns_service()");
RUN_EVENT_LOOP;