From 39f854d2b3fc7a5f40c669e715799bdc61510ea7 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 16:27:43 +0100 Subject: [PATCH] Fixes for pedantic warnings --- src/extension/default_eventloop.c | 13 +++++++++++-- src/test/getdns_query.c | 3 +++ src/types-internal.h | 32 +++++++++++++++---------------- src/ub_loop.c | 4 ++-- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index b05d8ec3..e83d9b89 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -83,7 +83,7 @@ default_eventloop_schedule(getdns_eventloop *loop, #endif default_loop->fd_events[fd] = event; default_loop->fd_timeout_times[fd] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) fd + 1; + event->ev = (void *) (intptr_t) (fd + 1); DEBUG_SCHED( "scheduled read/write at %d\n", fd); return GETDNS_RETURN_GOOD; @@ -104,7 +104,7 @@ default_eventloop_schedule(getdns_eventloop *loop, if (default_loop->timeout_events[i] == NULL) { default_loop->timeout_events[i] = event; default_loop->timeout_times[i] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) i + 1; + event->ev = (void *) (intptr_t) (i + 1); DEBUG_SCHED( "scheduled timeout at %d\n", (int)i); return GETDNS_RETURN_GOOD; @@ -159,6 +159,9 @@ default_eventloop_cleanup(getdns_eventloop *loop) static void default_read_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->read_cb(event->userarg); } @@ -166,6 +169,9 @@ default_read_cb(int fd, getdns_eventloop_event *event) static void default_write_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->write_cb(event->userarg); } @@ -173,6 +179,9 @@ default_write_cb(int fd, getdns_eventloop_event *event) static void default_timeout_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->timeout_cb(event->userarg); } diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c index 4e8b2d4a..8230b7ef 100644 --- a/src/test/getdns_query.c +++ b/src/test/getdns_query.c @@ -1284,6 +1284,9 @@ static void request_cb( getdns_return_t r = GETDNS_RETURN_GOOD; uint32_t n, rcode, dnssec_status; +#if !defined(SERVER_DEBUG) || !SERVER_DEBUG + (void)transaction_id; +#endif DEBUG_SERVER("reply for: %p %"PRIu64" %d (edns0: %d, do: %d, ad: %d," " cd: %d)\n", msg, transaction_id, (int)callback_type, msg->has_edns0, msg->do_bit, msg->ad_bit, msg->cd_bit); diff --git a/src/types-internal.h b/src/types-internal.h index b321bafa..37588e7a 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -278,29 +278,29 @@ typedef struct getdns_dns_req { getdns_append_name_t append_name; const uint8_t *suffix; size_t suffix_len; - int suffix_appended : 1; + unsigned suffix_appended : 1; /* canceled flag */ - int canceled : 1; + unsigned canceled : 1; /* request extensions */ - int dnssec_return_status : 1; - int dnssec_return_only_secure : 1; - int dnssec_return_all_statuses : 1; - int dnssec_return_validation_chain : 1; - int dnssec_return_full_validation_chain : 1; + unsigned dnssec_return_status : 1; + unsigned dnssec_return_only_secure : 1; + unsigned dnssec_return_all_statuses : 1; + unsigned dnssec_return_validation_chain : 1; + unsigned dnssec_return_full_validation_chain : 1; #ifdef DNSSEC_ROADBLOCK_AVOIDANCE - int dnssec_roadblock_avoidance : 1; - int avoid_dnssec_roadblocks : 1; + unsigned dnssec_roadblock_avoidance : 1; + unsigned avoid_dnssec_roadblocks : 1; #endif - int edns_cookies : 1; - int edns_client_subnet_private : 1; - int return_call_reporting : 1; - int add_warning_for_bad_dns : 1; + unsigned edns_cookies : 1; + unsigned edns_client_subnet_private : 1; + unsigned return_call_reporting : 1; + unsigned add_warning_for_bad_dns : 1; /* Internally used by return_validation_chain */ - int dnssec_ok_checking_disabled : 1; - int is_sync_request : 1; + unsigned dnssec_ok_checking_disabled : 1; + unsigned is_sync_request : 1; /* The validating and freed variables are used to make sure a single * code path is followed while processing a DNS request, even when @@ -310,7 +310,7 @@ typedef struct getdns_dns_req { * validating is touched by _getdns_get_validation_chain only and * freed is touched by _getdns_submit_netreq only */ - int validating : 1; + unsigned validating : 1; int *freed; uint16_t tls_query_padding_blocksize; diff --git a/src/ub_loop.c b/src/ub_loop.c index c0040289..1fc9daa7 100644 --- a/src/ub_loop.c +++ b/src/ub_loop.c @@ -115,9 +115,9 @@ typedef struct my_event { } my_event; #define AS_UB_LOOP(x) \ - (((union {struct ub_event_base* a; _getdns_ub_loop* b;})x).b) + ((_getdns_ub_loop *)(x)) #define AS_MY_EVENT(x) \ - (((union {struct ub_event* a; my_event* b;})x).b) + ((my_event *)(x)) static void my_event_base_free(struct ub_event_base* base) {