diff --git a/configure.ac b/configure.ac index 282b3990..f68aaf36 100644 --- a/configure.ac +++ b/configure.ac @@ -95,9 +95,16 @@ AC_PROG_CPP AC_CANONICAL_HOST CFLAGS="$CFLAGS" +WPEDANTICFLAG="" +WNOERRORFLAG="" AC_PROG_CC_C99 AX_CHECK_COMPILE_FLAG([-xc99],[CFLAGS="$CFLAGS -xc99"],[],[]) AX_CHECK_COMPILE_FLAG([-Wall],[CFLAGS="$CFLAGS -Wall"],[],[]) +AX_CHECK_COMPILE_FLAG([-Wextra],[CFLAGS="$CFLAGS -Wextra"],[],[]) +AX_CHECK_COMPILE_FLAG([-Wpedantic],[WPEDANTICFLAG="-Wpedantic"],[],[]) +AX_CHECK_COMPILE_FLAG([-Wno-error=unused-parameter],[WNOERRORFLAG="-Wno-error=unused-parameter"],[],[]) +AC_SUBST(WPEDANTICFLAG) +AC_SUBST(WNOERRORFLAG) case "$host_os" in linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE" diff --git a/src/Makefile.in b/src/Makefile.in index 3766b318..fb637e3e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -48,7 +48,9 @@ srcdir = @srcdir@ LIBTOOL = ../libtool CC=@CC@ -CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ +CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS) +WPEDANTICFLAG=@WPEDANTICFLAG@ +WNOERRORFLAG=@WNOERRORFLAG@ LDFLAGS=@LDFLAGS@ @LIBS@ EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@ @@ -83,35 +85,35 @@ NON_C99_OBJS=context.lo libuv.lo .SUFFIXES: .c .o .a .lo .h .c.o: - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@ .c.lo: - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@ default: all all: libgetdns.la $(EXTENSION_LIBEVENT_LIB) $(EXTENSION_LIBUV_LIB) $(EXTENSION_LIBEV_LIB) $(GETDNS_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/$(@:.lo=.c) -o $@ $(GLDNS_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/gldns/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/gldns/$(@:.lo=.c) -o $@ $(COMPAT_OBJ): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/compat/$(@:.lo=.c) -o $@ $(UTIL_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/util/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WNOERRORFLAG) -c $(srcdir)/util/$(@:.lo=.c) -o $@ $(EXTENSION_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/extension/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/extension/$(@:.lo=.c) -o $@ context.lo: - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(C99COMPATFLAGS) -c $(srcdir)/context.c -o context.lo + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) $(C99COMPATFLAGS) -c $(srcdir)/context.c -o context.lo libuv.lo: - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(C99COMPATFLAGS) -c $(srcdir)/extension/libuv.c -o libuv.lo + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) $(C99COMPATFLAGS) -c $(srcdir)/extension/libuv.c -o libuv.lo install: libgetdns.la $(INSTALL) -m 755 -d $(DESTDIR)$(includedir) @@ -134,18 +136,18 @@ uninstall: if test $(have_libev) = 1; then $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$(EXTENSION_LIBEV_LIB) ; fi libgetdns_ext_event.la: libgetdns.la libevent.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libevent.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libevent.symbols + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libevent.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libevent.symbols libgetdns_ext_uv.la: libgetdns.la libuv.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libuv.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libuv.symbols + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libuv.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libuv.symbols libgetdns_ext_ev.la: libgetdns.la libev.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ libev.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libev.symbols + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ libev.lo libgetdns.la $(LDFLAGS) $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/extension/libev.symbols libgetdns.la: $(GETDNS_OBJ) version.lo context.lo default_eventloop.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ $(GETDNS_OBJ) version.lo context.lo default_eventloop.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ $(GETDNS_OBJ) version.lo context.lo default_eventloop.lo $(GLDNS_OBJ) $(COMPAT_OBJ) $(UTIL_OBJ) $(LDFLAGS) -rpath $(libdir) -version-info $(libversion) -no-undefined -export-symbols $(srcdir)/libgetdns.symbols test: all diff --git a/src/context.c b/src/context.c index ebe45ccb..17e4fb2d 100644 --- a/src/context.c +++ b/src/context.c @@ -723,8 +723,11 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) } static int -tls_is_in_transports_list(getdns_context *context) { - for (size_t i=0; i< context->dns_transport_count;i++) { +tls_is_in_transports_list(getdns_context *context) +{ + size_t i; + + for (i = 0; i< context->dns_transport_count;i++) { if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS) return 1; } @@ -1894,11 +1897,13 @@ getdns_context_set_tls_authentication(getdns_context *context, return GETDNS_RETURN_GOOD; } /* getdns_context_set_tls_authentication_list */ +#ifdef HAVE_LIBUNBOUND static void -set_ub_limit_outstanding_queries(struct getdns_context* context, uint16_t value) { +set_ub_limit_outstanding_queries(getdns_context* context, uint16_t value) { /* num-queries-per-thread */ set_ub_number_opt(context, "num-queries-per-thread:", value); } +#endif /* * getdns_context_set_limit_outstanding_queries * @@ -1908,7 +1913,9 @@ getdns_context_set_limit_outstanding_queries(struct getdns_context *context, uint16_t limit) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); +#ifdef HAVE_LIBUNBOUND set_ub_limit_outstanding_queries(context, limit); +#endif if (limit != context->limit_outstanding_queries) { context->limit_outstanding_queries = limit; dispatch_updated(context, @@ -2280,11 +2287,13 @@ getdns_context_set_dnssec_trust_anchors( return GETDNS_RETURN_GOOD; } /* getdns_context_set_dnssec_trust_anchors */ +#ifdef HAVE_LIBUNBOUND static void set_ub_dnssec_allowed_skew(struct getdns_context* context, uint32_t value) { set_ub_number_opt(context, "val-sig-skew-min:", value); set_ub_number_opt(context, "val-sig-skew-max:", value); } +#endif /* * getdns_context_set_dnssec_allowed_skew * @@ -2294,7 +2303,9 @@ getdns_context_set_dnssec_allowed_skew(struct getdns_context *context, uint32_t value) { RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); +#ifdef HAVE_LIBUNBOUND set_ub_dnssec_allowed_skew(context, value); +#endif if (value != context->dnssec_allowed_skew) { context->dnssec_allowed_skew = value; dispatch_updated(context, GETDNS_CONTEXT_CODE_DNSSEC_ALLOWED_SKEW); @@ -2562,6 +2573,7 @@ error: } /* getdns_context_set_upstream_recursive_servers */ +#ifdef HAVE_LIBUNBOUND static void set_ub_edns_maximum_udp_payload_size(struct getdns_context* context, int value) { @@ -2569,6 +2581,7 @@ set_ub_edns_maximum_udp_payload_size(struct getdns_context* context, if (value >= 512 && value <= 65535) set_ub_number_opt(context, "edns-buffer-size:", (uint16_t)value); } +#endif /* * getdns_context_set_edns_maximum_udp_payload_size @@ -2585,7 +2598,9 @@ getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context, if (value < 512) value = 512; +#ifdef HAVE_LIBUNBOUND set_ub_edns_maximum_udp_payload_size(context, value); +#endif if (value != context->edns_maximum_udp_payload_size) { context->edns_maximum_udp_payload_size = value; dispatch_updated(context, @@ -2986,7 +3001,7 @@ getdns_return_t _getdns_context_prepare_for_resolution(struct getdns_context *context, int usenamespaces) { - int i; + size_t i; getdns_return_t r; RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); @@ -3472,7 +3487,7 @@ _getdns_context_local_namespace_resolve( getdns_context *context = dnsreq->context; host_name_addrs *hnas; uint8_t lookup[256]; - getdns_list empty_list = { 0 }; + getdns_list empty_list = { 0, 0, NULL, { NULL, {{ NULL, NULL, NULL }}}}; getdns_bindata bindata; getdns_list *jaa; size_t i; diff --git a/src/context.h b/src/context.h index 46ed6c88..86bfb817 100644 --- a/src/context.h +++ b/src/context.h @@ -192,7 +192,7 @@ struct getdns_context { /* Context values */ getdns_resolution_t resolution_type; getdns_namespace_t *namespaces; - int namespace_count; + size_t namespace_count; uint64_t timeout; uint64_t idle_timeout; getdns_redirects_t follow_redirects; diff --git a/src/convert.c b/src/convert.c index 353e6abc..055abf96 100644 --- a/src/convert.c +++ b/src/convert.c @@ -53,9 +53,6 @@ #include "convert.h" #include "debug.h" -/* stuff to make it compile pedantically */ -#define UNUSED_PARAM(x) ((void)(x)) - /* strdup is marked deprecated by the Windows compiler */ #ifndef STRDUP #ifdef GETDNS_ON_WINDOWS @@ -64,6 +61,7 @@ #define STRDUP(x) strdup(x) #endif #endif + getdns_return_t getdns_convert_dns_name_to_fqdn( const getdns_bindata *dns_name_wire_fmt, char **fqdn_as_string) diff --git a/src/dict.c b/src/dict.c index 0ab0c784..eba1a728 100644 --- a/src/dict.c +++ b/src/dict.c @@ -54,7 +54,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf, - const char *jptr, char *first, size_t first_sz) + const char *jptr, char *first, ssize_t first_sz) { const char *next_ref, *k; char *j; @@ -735,14 +735,13 @@ _getdns_bindata_is_dname(getdns_bindata *bindata) /** * private function to pretty print bindata to a gldns_buffer * @param buf buffer to write to - * @param indent number of spaces to append after newline * @param bindata the bindata to print * @return on success the number of written characters * if an output error is encountered, a negative value */ static int -getdns_pp_bindata(gldns_buffer *buf, size_t indent, - getdns_bindata *bindata, int rdata_raw, int json) +getdns_pp_bindata(gldns_buffer *buf, getdns_bindata *bindata, + int rdata_raw, int json) { size_t i, p = gldns_buffer_position(buf); uint8_t *dptr; @@ -887,7 +886,7 @@ getdns_pp_list(gldns_buffer *buf, size_t indent, const getdns_list *list, GETDNS_RETURN_GOOD) return -1; if (getdns_pp_bindata( - buf, indent, bindata_item, 0, json) < 0) + buf, bindata_item, 0, json) < 0) return -1; break; @@ -1096,7 +1095,7 @@ getdns_pp_dict(gldns_buffer * buf, size_t indent, return -1; } else if (getdns_pp_bindata( - buf, indent, item->i.data.bindata, + buf, item->i.data.bindata, (strcmp(item->node.key, "rdata_raw") == 0), json) < 0) return -1; @@ -1189,7 +1188,7 @@ getdns_pretty_snprint_dict(char *str, size_t size, const getdns_dict *dict) gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, 0) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1223,7 +1222,7 @@ getdns_pretty_snprint_list(char *str, size_t size, const getdns_list *list) gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, 0) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1258,7 +1257,7 @@ getdns_snprint_json_dict( gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_dict(&buf, 0, dict, pretty ? 1 : 2) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } char * @@ -1293,7 +1292,7 @@ getdns_snprint_json_list( gldns_buffer_init_frm_data(&buf, str, size); return getdns_pp_list(&buf, 0, list, 0, pretty ? 1 : 2) < 0 - ? -1 : gldns_buffer_position(&buf); + ? -1 : (int)gldns_buffer_position(&buf); } /* dict.c */ diff --git a/src/dnssec.c b/src/dnssec.c index 965ee081..ec4c9199 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -256,7 +256,7 @@ static uint8_t *_dname_label_copy(uint8_t *dst, const uint8_t *src, size_t dst_l { uint8_t *r = dst, i; - if (!src || (unsigned)(*src + 1) > dst_len) + if (!src || (size_t)*src + 1 > dst_len) return NULL; for (i = (*dst++ = *src++); i ; i--) @@ -528,7 +528,7 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf, chain_head *head; const uint8_t *labels[128], **last_label, **label; - size_t max_labels; /* max labels in common */ + ssize_t max_labels; /* max labels in common */ chain_head *max_head; chain_node *max_node; @@ -857,6 +857,7 @@ static getdns_dict *CD_extension(getdns_dns_req *dnsreq) ? dnssec_ok_checking_disabled_roadblock_avoidance : dnssec_ok_checking_disabled_avoid_roadblocks; #else + (void)dnsreq; return dnssec_ok_checking_disabled; #endif } @@ -1871,7 +1872,7 @@ static int ds_authenticates_keys(struct mem_funcs *mf, max_supported_digest = ds->rr_i.rr_type[13]; max_supported_result = 0; - if (digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14 + if ((int)digest_len != ds->rr_i.nxt - ds->rr_i.rr_type-14 || memcmp(digest, ds->rr_i.rr_type+14, digest_len) != 0) { if (digest != digest_spc) GETDNS_FREE(*mf, digest); diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index b6ad5586..ce010bc0 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -29,6 +29,7 @@ #include "extension/default_eventloop.h" #include "debug.h" +#include "types-internal.h" static uint64_t get_now_plus(uint64_t amount) { @@ -41,7 +42,8 @@ static uint64_t get_now_plus(uint64_t amount) } now = tv.tv_sec * 1000000 + tv.tv_usec; - return (now + amount * 1000) >= now ? now + amount * 1000 : -1; + return (now + amount * 1000) >= now + ? now + amount * 1000 : TIMEOUT_FOREVER; } static getdns_return_t @@ -151,11 +153,15 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) static void default_eventloop_cleanup(getdns_eventloop *loop) { + (void)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); } @@ -163,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); } @@ -170,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); } @@ -181,7 +193,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) fd_set readfds, writefds; int fd, max_fd = -1; - uint64_t now, timeout = (uint64_t)-1; + uint64_t now, timeout = TIMEOUT_FOREVER; size_t i; struct timeval tv; @@ -212,7 +224,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) if (default_loop->fd_timeout_times[fd] < timeout) timeout = default_loop->fd_timeout_times[fd]; } - if (max_fd == -1 && timeout == (uint64_t)-1) + if (max_fd == -1 && timeout == TIMEOUT_FOREVER) return; if (! blocking || now > timeout) { @@ -223,7 +235,7 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) tv.tv_usec = (long)((timeout - now) % 1000000); } if (select(max_fd + 1, &readfds, &writefds, NULL, - (timeout == ((uint64_t)-1) ? NULL : &tv)) < 0) { + (timeout == TIMEOUT_FOREVER ? NULL : &tv)) < 0) { perror("select() failed"); exit(EXIT_FAILURE); } diff --git a/src/extension/libev.c b/src/extension/libev.c index 6a8c26e9..ff36b5c2 100644 --- a/src/extension/libev.c +++ b/src/extension/libev.c @@ -97,6 +97,7 @@ static void getdns_libev_read_cb(struct ev_loop *l, struct ev_io *io, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data; + (void)l; (void)revents; assert(el_ev->read_cb); el_ev->read_cb(el_ev->userarg); } @@ -105,14 +106,16 @@ static void getdns_libev_write_cb(struct ev_loop *l, struct ev_io *io, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)io->data; + (void)l; (void)revents; assert(el_ev->write_cb); el_ev->write_cb(el_ev->userarg); } static void -getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revent) +getdns_libev_timeout_cb(struct ev_loop *l, struct ev_timer *timer, int revents) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)timer->data; + (void)l; (void)revents; assert(el_ev->timeout_cb); el_ev->timeout_cb(el_ev->userarg); } diff --git a/src/extension/libevent.c b/src/extension/libevent.c index 800ebe8e..d096d347 100644 --- a/src/extension/libevent.c +++ b/src/extension/libevent.c @@ -95,6 +95,7 @@ static getdns_return_t getdns_libevent_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) { struct event *my_ev = (struct event *)el_ev->ev; + (void)loop; assert(my_ev); @@ -110,6 +111,7 @@ static void getdns_libevent_callback(evutil_socket_t fd, short bits, void *arg) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)arg; + (void)fd; if (bits & EV_READ) { assert(el_ev->read_cb); diff --git a/src/extension/libuv.c b/src/extension/libuv.c index adf97835..ec9257be 100644 --- a/src/extension/libuv.c +++ b/src/extension/libuv.c @@ -104,6 +104,7 @@ getdns_libuv_clear(getdns_eventloop *loop, getdns_eventloop_event *el_ev) poll_timer *my_ev = (poll_timer *)el_ev->ev; uv_poll_t *my_poll; uv_timer_t *my_timer; + (void)loop; assert(my_ev); @@ -141,6 +142,7 @@ static void getdns_libuv_read_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; + (void)status; (void)events; assert(el_ev->read_cb); DEBUG_UV("enter libuv_read_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); @@ -153,6 +155,7 @@ static void getdns_libuv_write_cb(uv_poll_t *poll, int status, int events) { getdns_eventloop_event *el_ev = (getdns_eventloop_event *)poll->data; + (void)status; (void)events; assert(el_ev->write_cb); DEBUG_UV("enter libuv_write_cb(el_ev = %p, el_ev->ev = %p)\n" , el_ev, el_ev->ev); diff --git a/src/gldns/str2wire.c b/src/gldns/str2wire.c index 4550a29a..89844f13 100644 --- a/src/gldns/str2wire.c +++ b/src/gldns/str2wire.c @@ -328,7 +328,7 @@ rrinternal_write_typeclassttl(gldns_buffer* strbuf, uint8_t* rr, size_t len, /** find delimiters for type */ static const char* -rrinternal_get_delims(gldns_rdf_type rdftype, uint16_t r_cnt, uint16_t r_max) +rrinternal_get_delims(gldns_rdf_type rdftype, size_t r_cnt, size_t r_max) { switch(rdftype) { case GLDNS_RDF_TYPE_B64 : @@ -463,7 +463,7 @@ rrinternal_parse_unknown(gldns_buffer* strbuf, char* token, size_t token_len, static int rrinternal_parse_rdf(gldns_buffer* strbuf, char* token, size_t token_len, uint8_t* rr, size_t rr_len, size_t* rr_cur_len, gldns_rdf_type rdftype, - uint16_t rr_type, uint16_t r_cnt, uint16_t r_max, size_t dname_len, + uint16_t rr_type, size_t r_cnt, size_t r_max, size_t dname_len, uint8_t* origin, size_t origin_len) { size_t len; @@ -613,7 +613,7 @@ rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len, uint8_t* origin, size_t origin_len) { const gldns_rr_descriptor *desc = gldns_rr_descript((uint16_t)rr_type); - uint16_t r_cnt, r_min, r_max; + size_t r_cnt, r_min, r_max; size_t rr_cur_len = dname_len + 10, pre_data_pos, token_strlen; int was_unknown_rr_format = 0, parens = 0, status, quoted; const char* delimiters; @@ -693,7 +693,7 @@ rrinternal_parse_rdata(gldns_buffer* strbuf, char* token, size_t token_len, gldns_buffer_position(strbuf)); } /* write rdata length */ - gldns_write_uint16(rr+dname_len+8, rr_cur_len-dname_len-10); + gldns_write_uint16(rr+dname_len+8, (uint16_t)(rr_cur_len-dname_len-10)); *rr_len = rr_cur_len; return GLDNS_WIREPARSE_ERR_OK; } @@ -1369,7 +1369,7 @@ int gldns_str2wire_time_buf(const char* str, uint8_t* rd, size_t* len) if (tm.tm_sec < 0 || tm.tm_sec > 59) return GLDNS_WIREPARSE_ERR_SYNTAX_TIME; - gldns_write_uint32(rd, gldns_mktime_from_utc(&tm)); + gldns_write_uint32(rd, (uint32_t)gldns_mktime_from_utc(&tm)); } else { /* handle it as 32 bits timestamp */ char *end; @@ -1932,7 +1932,7 @@ int gldns_str2wire_tag_buf(const char* str, uint8_t* rd, size_t* len) if(!isalnum((unsigned char)*ptr)) return RET_ERR(GLDNS_WIREPARSE_ERR_SYNTAX_TAG, ptr-str); } - rd[0] = slen; + rd[0] = (uint8_t)slen; memmove(rd+1, str, slen); *len = slen+1; return GLDNS_WIREPARSE_ERR_OK; @@ -2000,7 +2000,7 @@ int gldns_str2wire_hip_buf(const char* str, uint8_t* rd, size_t* len) return RET_ERR_SHIFT(e, s-(char*)str); if(pklen > 65535) return RET_ERR(GLDNS_WIREPARSE_ERR_LABEL_OVERFLOW, s-(char*)str+65535); - gldns_write_uint16(rd+2, pklen); + gldns_write_uint16(rd+2, (uint16_t)pklen); *len = 4 + hitlen + pklen; return GLDNS_WIREPARSE_ERR_OK; diff --git a/src/gldns/wire2str.c b/src/gldns/wire2str.c index abc055d7..50d00967 100644 --- a/src/gldns/wire2str.c +++ b/src/gldns/wire2str.c @@ -668,7 +668,7 @@ int gldns_wire2str_rdata_scan(uint8_t** d, size_t* dlen, char** s, uint8_t* origd = *d; char* origs = *s; size_t origdlen = *dlen, origslen = *slen; - uint16_t r_cnt, r_max; + size_t r_cnt, r_max; gldns_rdf_type rdftype; int w = 0, n; @@ -789,8 +789,9 @@ int gldns_wire2str_dname_scan(uint8_t** d, size_t* dlen, char** s, size_t* slen, } /* spool label characters, end with '.' */ - if(in_buf && *dlen < labellen) labellen = *dlen; - else if(!in_buf && pos+labellen > pkt+pktlen) + if(in_buf && *dlen < (size_t)labellen) + labellen = (uint8_t)*dlen; + else if(!in_buf && pos+(size_t)labellen > pkt+pktlen) labellen = (uint8_t)(pkt + pktlen - pos); for(i=0; i<(unsigned)labellen; i++) { w += dname_char_print(s, slen, *pos++); @@ -1983,10 +1984,10 @@ int gldns_wire2str_edns_scan(uint8_t** data, size_t* data_len, char** str, w += gldns_str_print(str, str_len, " ; udp: %u", (unsigned)udpsize); if(rdatalen) { - if(*data_len < rdatalen) { + if((size_t)*data_len < rdatalen) { w += gldns_str_print(str, str_len, " ; Error EDNS rdata too short; "); - rdatalen = *data_len; + rdatalen = (uint16_t)*data_len; } w += print_edns_opts(str, str_len, *data, rdatalen); (*data) += rdatalen; diff --git a/src/list.c b/src/list.c index 486b227b..4a73b63f 100644 --- a/src/list.c +++ b/src/list.c @@ -312,7 +312,7 @@ getdns_return_t _getdns_list_copy(const struct getdns_list * srclist, struct getdns_list ** dstlist) { - unsigned int i; + size_t i; getdns_return_t retval; if (!dstlist) diff --git a/src/pubkey-pinning.c b/src/pubkey-pinning.c index 7d286691..db60fbc8 100644 --- a/src/pubkey-pinning.c +++ b/src/pubkey-pinning.c @@ -97,7 +97,7 @@ getdns_dict* getdns_pubkey_pin_create_from_string( const char* str) { BIO *bio = NULL; - int i; + size_t i; uint8_t buf[SHA256_DIGEST_LENGTH]; char inbuf[B64_ENCODED_SHA256_LENGTH + 1]; getdns_bindata value = { .size = SHA256_DIGEST_LENGTH, .data = buf }; @@ -425,7 +425,7 @@ _getdns_verify_pinset_match(const sha256_pin_t *pinset, #endif /* digest the cert with sha256 */ len = i2d_X509_PUBKEY(X509_get_X509_PUBKEY(x), NULL); - if (len > sizeof(raw)) { + if (len > (int)sizeof(raw)) { DEBUG_STUB("%s %-35s: Pubkey %d is larger than "PRIsz" octets\n", STUB_DEBUG_SETUP_TLS, __FUNCTION__, i, sizeof(raw)); continue; diff --git a/src/request-internal.c b/src/request-internal.c index 69166ace..4f2e7773 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -65,20 +65,20 @@ getdns_dict dnssec_ok_checking_disabled_spc = { { RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp }, - { 0 } + { NULL, {{ NULL, NULL, NULL }}} }; getdns_dict *dnssec_ok_checking_disabled = &dnssec_ok_checking_disabled_spc; getdns_dict dnssec_ok_checking_disabled_roadblock_avoidance_spc = { { RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp }, - { 0 } + { NULL, {{ NULL, NULL, NULL }}} }; getdns_dict *dnssec_ok_checking_disabled_roadblock_avoidance = &dnssec_ok_checking_disabled_roadblock_avoidance_spc; getdns_dict dnssec_ok_checking_disabled_avoid_roadblocks_spc = { { RBTREE_NULL, 0, (int (*)(const void *, const void *)) strcmp }, - { 0 } + { NULL, {{ NULL, NULL, NULL }}} }; getdns_dict *dnssec_ok_checking_disabled_avoid_roadblocks = &dnssec_ok_checking_disabled_avoid_roadblocks_spc; diff --git a/src/rr-dict.c b/src/rr-dict.c index 26504512..b269e19b 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -47,6 +47,7 @@ static const uint8_t * apl_n_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)pkt; return rdf < pkt_end ? rdf + 1 : NULL; } static getdns_return_t @@ -107,6 +108,7 @@ apl_afdpart_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { const uint8_t *end = rdf + (rdf[-1] & 0x7F); + (void)(pkt); return end <= pkt_end ? end : NULL; } static getdns_return_t @@ -335,6 +337,7 @@ static const uint8_t * hip_pk_algorithm_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 4 > pkt_end ? NULL : rdf + 4 + *rdf + gldns_read_uint16(rdf + 2) > pkt_end ? NULL : rdf + 1; @@ -397,6 +400,7 @@ static _getdns_rdf_special hip_pk_algorithm = { static const uint8_t * hip_hit_rdf_end(const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 3 > pkt_end ? NULL : rdf + 3 + rdf[-1] + gldns_read_uint16(rdf + 1) > pkt_end ? NULL : rdf + 1; @@ -467,6 +471,7 @@ static const uint8_t * hip_public_key_rdf_end( const uint8_t *pkt, const uint8_t *pkt_end, const uint8_t *rdf) { + (void)(pkt); return rdf + 2 > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf) > pkt_end ? NULL : rdf + 2 + rdf[-2] + gldns_read_uint16(rdf); @@ -537,222 +542,222 @@ static _getdns_rdf_special hip_public_key = { static _getdns_rdata_def a_rdata[] = { - { "ipv4_address" , GETDNS_RDF_A }}; + { "ipv4_address" , GETDNS_RDF_A , NULL }}; static _getdns_rdata_def ns_rdata[] = { - { "nsdname" , GETDNS_RDF_N_C }}; + { "nsdname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def md_rdata[] = { - { "madname" , GETDNS_RDF_N_C }}; + { "madname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def cname_rdata[] = { - { "cname" , GETDNS_RDF_N_C }}; + { "cname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def soa_rdata[] = { - { "mname" , GETDNS_RDF_N_C }, - { "rname" , GETDNS_RDF_N_C }, - { "serial" , GETDNS_RDF_I4 }, - { "refresh" , GETDNS_RDF_I4 }, - { "retry" , GETDNS_RDF_I4 }, - { "expire" , GETDNS_RDF_I4 }, - { "minimum" , GETDNS_RDF_I4 }}; + { "mname" , GETDNS_RDF_N_C , NULL }, + { "rname" , GETDNS_RDF_N_C , NULL }, + { "serial" , GETDNS_RDF_I4 , NULL }, + { "refresh" , GETDNS_RDF_I4 , NULL }, + { "retry" , GETDNS_RDF_I4 , NULL }, + { "expire" , GETDNS_RDF_I4 , NULL }, + { "minimum" , GETDNS_RDF_I4 , NULL }}; static _getdns_rdata_def mg_rdata[] = { - { "mgmname" , GETDNS_RDF_N_C }}; + { "mgmname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def mr_rdata[] = { - { "newname" , GETDNS_RDF_N_C }}; + { "newname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def null_rdata[] = { - { "anything" , GETDNS_RDF_X }}; + { "anything" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def wks_rdata[] = { - { "address" , GETDNS_RDF_A }, - { "protocol" , GETDNS_RDF_I1 }, - { "bitmap" , GETDNS_RDF_X }}; + { "address" , GETDNS_RDF_A , NULL }, + { "protocol" , GETDNS_RDF_I1 , NULL }, + { "bitmap" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def ptr_rdata[] = { - { "ptrdname" , GETDNS_RDF_N_C }}; + { "ptrdname" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def hinfo_rdata[] = { - { "cpu" , GETDNS_RDF_S }, - { "os" , GETDNS_RDF_S }}; + { "cpu" , GETDNS_RDF_S , NULL }, + { "os" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def minfo_rdata[] = { - { "rmailbx" , GETDNS_RDF_N_C }, - { "emailbx" , GETDNS_RDF_N_C }}; + { "rmailbx" , GETDNS_RDF_N_C , NULL }, + { "emailbx" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def mx_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "exchange" , GETDNS_RDF_N_C }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "exchange" , GETDNS_RDF_N_C , NULL }}; static _getdns_rdata_def txt_rdata[] = { - { "txt_strings" , GETDNS_RDF_S_M }}; + { "txt_strings" , GETDNS_RDF_S_M , NULL }}; static _getdns_rdata_def rp_rdata[] = { - { "mbox_dname" , GETDNS_RDF_N }, - { "txt_dname" , GETDNS_RDF_N }}; + { "mbox_dname" , GETDNS_RDF_N , NULL }, + { "txt_dname" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def afsdb_rdata[] = { - { "subtype" , GETDNS_RDF_I2 }, - { "hostname" , GETDNS_RDF_N }}; + { "subtype" , GETDNS_RDF_I2 , NULL }, + { "hostname" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def x25_rdata[] = { - { "psdn_address" , GETDNS_RDF_S }}; + { "psdn_address" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def isdn_rdata[] = { - { "isdn_address" , GETDNS_RDF_S }, - { "sa" , GETDNS_RDF_S }}; + { "isdn_address" , GETDNS_RDF_S , NULL }, + { "sa" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def rt_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "intermediate_host" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "intermediate_host" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def nsap_rdata[] = { - { "nsap" , GETDNS_RDF_X }}; + { "nsap" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def sig_rdata[] = { - { "sig_obsolete" , GETDNS_RDF_X }}; + { "sig_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def key_rdata[] = { - { "key_obsolete" , GETDNS_RDF_X }}; + { "key_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def px_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "map822" , GETDNS_RDF_N }, - { "mapx400" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "map822" , GETDNS_RDF_N , NULL }, + { "mapx400" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def gpos_rdata[] = { - { "longitude" , GETDNS_RDF_S }, - { "latitude" , GETDNS_RDF_S }, - { "altitude" , GETDNS_RDF_S }}; + { "longitude" , GETDNS_RDF_S , NULL }, + { "latitude" , GETDNS_RDF_S , NULL }, + { "altitude" , GETDNS_RDF_S , NULL }}; static _getdns_rdata_def aaaa_rdata[] = { - { "ipv6_address" , GETDNS_RDF_AAAA }}; + { "ipv6_address" , GETDNS_RDF_AAAA , NULL }}; static _getdns_rdata_def loc_rdata[] = { - { "loc_obsolete" , GETDNS_RDF_X }}; + { "loc_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def nxt_rdata[] = { - { "nxt_obsolete" , GETDNS_RDF_X }}; + { "nxt_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def srv_rdata[] = { - { "priority" , GETDNS_RDF_I2 }, - { "weight" , GETDNS_RDF_I2 }, - { "port" , GETDNS_RDF_I2 }, - { "target" , GETDNS_RDF_N }}; + { "priority" , GETDNS_RDF_I2 , NULL }, + { "weight" , GETDNS_RDF_I2 , NULL }, + { "port" , GETDNS_RDF_I2 , NULL }, + { "target" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def atma_rdata[] = { - { "format" , GETDNS_RDF_X }}; + { "format" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def naptr_rdata[] = { - { "order" , GETDNS_RDF_I2 }, - { "preference" , GETDNS_RDF_I2 }, - { "flags" , GETDNS_RDF_S }, - { "service" , GETDNS_RDF_S }, - { "regexp" , GETDNS_RDF_S }, - { "replacement" , GETDNS_RDF_N }}; + { "order" , GETDNS_RDF_I2 , NULL }, + { "preference" , GETDNS_RDF_I2 , NULL }, + { "flags" , GETDNS_RDF_S , NULL }, + { "service" , GETDNS_RDF_S , NULL }, + { "regexp" , GETDNS_RDF_S , NULL }, + { "replacement" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def kx_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "exchanger" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "exchanger" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def cert_rdata[] = { - { "type" , GETDNS_RDF_I2 }, - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "certificate_or_crl" , GETDNS_RDF_B }}; + { "type" , GETDNS_RDF_I2 , NULL }, + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "certificate_or_crl" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def a6_rdata[] = { - { "a6_obsolete" , GETDNS_RDF_X }}; + { "a6_obsolete" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def dname_rdata[] = { - { "target" , GETDNS_RDF_N }}; + { "target" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def opt_rdata[] = { - { "options" , GETDNS_RDF_R }, - { "option_code" , GETDNS_RDF_I2 }, - { "option_data" , GETDNS_RDF_X_S }}; + { "options" , GETDNS_RDF_R , NULL }, + { "option_code" , GETDNS_RDF_I2 , NULL }, + { "option_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def apl_rdata[] = { - { "apitems" , GETDNS_RDF_R }, - { "address_family" , GETDNS_RDF_I2 }, - { "prefix" , GETDNS_RDF_I1 }, + { "apitems" , GETDNS_RDF_R , NULL }, + { "address_family" , GETDNS_RDF_I2 , NULL }, + { "prefix" , GETDNS_RDF_I1 , NULL }, { "n" , GETDNS_RDF_SPECIAL, &apl_n }, { "afdpart" , GETDNS_RDF_SPECIAL, &apl_afdpart }}; static _getdns_rdata_def ds_rdata[] = { - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "digest_type" , GETDNS_RDF_I1 }, - { "digest" , GETDNS_RDF_X }}; + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "digest_type" , GETDNS_RDF_I1 , NULL }, + { "digest" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def sshfp_rdata[] = { - { "algorithm" , GETDNS_RDF_I1 }, - { "fp_type" , GETDNS_RDF_I1 }, - { "fingerprint" , GETDNS_RDF_X }}; + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "fp_type" , GETDNS_RDF_I1 , NULL }, + { "fingerprint" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def ipseckey_rdata[] = { - { "algorithm" , GETDNS_RDF_I1 }, - { "gateway_type" , GETDNS_RDF_I1 }, - { "precedence" , GETDNS_RDF_I1 }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "gateway_type" , GETDNS_RDF_I1 , NULL }, + { "precedence" , GETDNS_RDF_I1 , NULL }, { "gateway" , GETDNS_RDF_SPECIAL, &ipseckey_gateway }, - { "public_key" , GETDNS_RDF_B }}; + { "public_key" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def rrsig_rdata[] = { - { "type_covered" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "labels" , GETDNS_RDF_I1 }, - { "original_ttl" , GETDNS_RDF_I4 }, - { "signature_expiration" , GETDNS_RDF_T }, - { "signature_inception" , GETDNS_RDF_T }, - { "key_tag" , GETDNS_RDF_I2 }, - { "signers_name" , GETDNS_RDF_N }, - { "signature" , GETDNS_RDF_B }}; + { "type_covered" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "labels" , GETDNS_RDF_I1 , NULL }, + { "original_ttl" , GETDNS_RDF_I4 , NULL }, + { "signature_expiration" , GETDNS_RDF_T , NULL }, + { "signature_inception" , GETDNS_RDF_T , NULL }, + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "signers_name" , GETDNS_RDF_N , NULL }, + { "signature" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def nsec_rdata[] = { - { "next_domain_name" , GETDNS_RDF_N }, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "next_domain_name" , GETDNS_RDF_N , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def dnskey_rdata[] = { - { "flags" , GETDNS_RDF_I2 }, - { "protocol" , GETDNS_RDF_I1 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "public_key" , GETDNS_RDF_B }}; + { "flags" , GETDNS_RDF_I2 , NULL }, + { "protocol" , GETDNS_RDF_I1 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "public_key" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def dhcid_rdata[] = { - { "dhcid_opaque" , GETDNS_RDF_B }}; + { "dhcid_opaque" , GETDNS_RDF_B , NULL }}; static _getdns_rdata_def nsec3_rdata[] = { - { "hash_algorithm" , GETDNS_RDF_I1 }, - { "flags" , GETDNS_RDF_I1 }, - { "iterations" , GETDNS_RDF_I2 }, - { "salt" , GETDNS_RDF_X_C }, - { "next_hashed_owner_name" , GETDNS_RDF_B32_C}, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "hash_algorithm" , GETDNS_RDF_I1 , NULL }, + { "flags" , GETDNS_RDF_I1 , NULL }, + { "iterations" , GETDNS_RDF_I2 , NULL }, + { "salt" , GETDNS_RDF_X_C , NULL }, + { "next_hashed_owner_name" , GETDNS_RDF_B32_C , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def nsec3param_rdata[] = { - { "hash_algorithm" , GETDNS_RDF_I1 }, - { "flags" , GETDNS_RDF_I1 }, - { "iterations" , GETDNS_RDF_I2 }, - { "salt" , GETDNS_RDF_X_C }}; + { "hash_algorithm" , GETDNS_RDF_I1 , NULL }, + { "flags" , GETDNS_RDF_I1 , NULL }, + { "iterations" , GETDNS_RDF_I2 , NULL }, + { "salt" , GETDNS_RDF_X_C , NULL }}; static _getdns_rdata_def tlsa_rdata[] = { - { "certificate_usage" , GETDNS_RDF_I1 }, - { "selector" , GETDNS_RDF_I1 }, - { "matching_type" , GETDNS_RDF_I1 }, - { "certificate_association_data", GETDNS_RDF_X }}; + { "certificate_usage" , GETDNS_RDF_I1 , NULL }, + { "selector" , GETDNS_RDF_I1 , NULL }, + { "matching_type" , GETDNS_RDF_I1 , NULL }, + { "certificate_association_data", GETDNS_RDF_X , NULL }}; static _getdns_rdata_def hip_rdata[] = { { "pk_algorithm" , GETDNS_RDF_SPECIAL, &hip_pk_algorithm }, { "hit" , GETDNS_RDF_SPECIAL, &hip_hit }, { "public_key" , GETDNS_RDF_SPECIAL, &hip_public_key }, - { "rendezvous_servers" , GETDNS_RDF_N_M }}; + { "rendezvous_servers" , GETDNS_RDF_N_M , NULL }}; static _getdns_rdata_def csync_rdata[] = { - { "serial" , GETDNS_RDF_I4 }, - { "flags" , GETDNS_RDF_I2 }, - { "type_bit_maps" , GETDNS_RDF_X }}; + { "serial" , GETDNS_RDF_I4 , NULL }, + { "flags" , GETDNS_RDF_I2 , NULL }, + { "type_bit_maps" , GETDNS_RDF_X , NULL }}; static _getdns_rdata_def spf_rdata[] = { - { "text" , GETDNS_RDF_S_M }}; + { "text" , GETDNS_RDF_S_M , NULL }}; static _getdns_rdata_def nid_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "node_id" , GETDNS_RDF_AA }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "node_id" , GETDNS_RDF_AA , NULL }}; static _getdns_rdata_def l32_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "locator32" , GETDNS_RDF_A }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "locator32" , GETDNS_RDF_A , NULL }}; static _getdns_rdata_def l64_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "locator64" , GETDNS_RDF_AA }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "locator64" , GETDNS_RDF_AA , NULL }}; static _getdns_rdata_def lp_rdata[] = { - { "preference" , GETDNS_RDF_I2 }, - { "fqdn" , GETDNS_RDF_N }}; + { "preference" , GETDNS_RDF_I2 , NULL }, + { "fqdn" , GETDNS_RDF_N , NULL }}; static _getdns_rdata_def eui48_rdata[] = { - { "eui48_address" , GETDNS_RDF_X6 }}; + { "eui48_address" , GETDNS_RDF_X6 , NULL }}; static _getdns_rdata_def eui64_rdata[] = { - { "eui64_address" , GETDNS_RDF_X8 }}; + { "eui64_address" , GETDNS_RDF_X8 , NULL }}; static _getdns_rdata_def tkey_rdata[] = { - { "algorithm" , GETDNS_RDF_N }, - { "inception" , GETDNS_RDF_T }, - { "expiration" , GETDNS_RDF_T }, - { "mode" , GETDNS_RDF_I2 }, - { "error" , GETDNS_RDF_I2 }, - { "key_data" , GETDNS_RDF_X_S }, - { "other_data" , GETDNS_RDF_X_S }}; + { "algorithm" , GETDNS_RDF_N , NULL }, + { "inception" , GETDNS_RDF_T , NULL }, + { "expiration" , GETDNS_RDF_T , NULL }, + { "mode" , GETDNS_RDF_I2 , NULL }, + { "error" , GETDNS_RDF_I2 , NULL }, + { "key_data" , GETDNS_RDF_X_S , NULL }, + { "other_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def tsig_rdata[] = { - { "algorithm" , GETDNS_RDF_N }, - { "time_signed" , GETDNS_RDF_T6 }, - { "fudge" , GETDNS_RDF_I2 }, - { "mac" , GETDNS_RDF_X_S }, - { "original_id" , GETDNS_RDF_I2 }, - { "error" , GETDNS_RDF_I2 }, - { "other_data" , GETDNS_RDF_X_S }}; + { "algorithm" , GETDNS_RDF_N , NULL }, + { "time_signed" , GETDNS_RDF_T6 , NULL }, + { "fudge" , GETDNS_RDF_I2 , NULL }, + { "mac" , GETDNS_RDF_X_S , NULL }, + { "original_id" , GETDNS_RDF_I2 , NULL }, + { "error" , GETDNS_RDF_I2 , NULL }, + { "other_data" , GETDNS_RDF_X_S , NULL }}; static _getdns_rdata_def uri_rdata[] = { - { "priority" , GETDNS_RDF_I2 }, - { "weight" , GETDNS_RDF_I2 }, - { "target" , GETDNS_RDF_S_L }}; + { "priority" , GETDNS_RDF_I2 , NULL }, + { "weight" , GETDNS_RDF_I2 , NULL }, + { "target" , GETDNS_RDF_S_L , NULL }}; static _getdns_rdata_def caa_rdata[] = { - { "flags" , GETDNS_RDF_I1 }, - { "tag" , GETDNS_RDF_S }, - { "value" , GETDNS_RDF_S_L }}; + { "flags" , GETDNS_RDF_I1 , NULL }, + { "tag" , GETDNS_RDF_S , NULL }, + { "value" , GETDNS_RDF_S_L , NULL }}; static _getdns_rdata_def dlv_rdata[] = { - { "key_tag" , GETDNS_RDF_I2 }, - { "algorithm" , GETDNS_RDF_I1 }, - { "digest_type" , GETDNS_RDF_I1 }, - { "digest" , GETDNS_RDF_X }}; + { "key_tag" , GETDNS_RDF_I2 , NULL }, + { "algorithm" , GETDNS_RDF_I1 , NULL }, + { "digest_type" , GETDNS_RDF_I1 , NULL }, + { "digest" , GETDNS_RDF_X , NULL }}; static _getdns_rr_def _getdns_rr_defs[] = { { NULL, NULL, 0 }, diff --git a/src/rr-dict.h b/src/rr-dict.h index 6ab52b88..e19e0387 100644 --- a/src/rr-dict.h +++ b/src/rr-dict.h @@ -138,7 +138,7 @@ typedef struct _getdns_rdata_def { typedef struct _getdns_rr_def { const char *name; const _getdns_rdata_def *rdata; - int n_rdata_fields; + size_t n_rdata_fields; } _getdns_rr_def; const _getdns_rr_def *_getdns_rr_def_lookup(uint16_t rr_type); diff --git a/src/rr-iter.c b/src/rr-iter.c index 7c4d4962..ede6b2b5 100644 --- a/src/rr-iter.c +++ b/src/rr-iter.c @@ -75,8 +75,8 @@ find_rrtype(_getdns_rr_iter *i) /* Past the last RR in the pkt */ if (i->pkt && - (unsigned)(GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + - GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt)) <= i->n) + (size_t)GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + + GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n) goto done; for (pos = i->pos; pos + 4 < i->pkt_end; pos += *pos + 1) diff --git a/src/rr-iter.h b/src/rr-iter.h index 4eae4df1..eae61012 100644 --- a/src/rr-iter.h +++ b/src/rr-iter.h @@ -86,19 +86,19 @@ const uint8_t *_getdns_owner_if_or_as_decompressed( static inline _getdns_section _getdns_rr_iter_section(_getdns_rr_iter *i) { - return !i->pkt ? (i->nxt - i->rr_type == 4 ? SECTION_QUESTION - : SECTION_ANSWER ) - : i->n < GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION - : i->n < (unsigned)(GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt)) ? SECTION_ANSWER - : i->n < (unsigned)(GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt) - + GLDNS_NSCOUNT(i->pkt)) ? SECTION_AUTHORITY - : i->n < (unsigned)(GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt) - + GLDNS_NSCOUNT(i->pkt) - + GLDNS_ARCOUNT(i->pkt)) ? SECTION_ADDITIONAL - : SECTION_ANY; + return ! i->pkt ? (i->nxt - i->rr_type == 4 ? SECTION_QUESTION + : SECTION_ANSWER ) + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) ? SECTION_QUESTION + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + + GLDNS_ANCOUNT(i->pkt) ? SECTION_ANSWER + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + + GLDNS_ANCOUNT(i->pkt) + + GLDNS_NSCOUNT(i->pkt) ? SECTION_AUTHORITY + : i->n < (size_t)GLDNS_QDCOUNT(i->pkt) + + GLDNS_ANCOUNT(i->pkt) + + GLDNS_NSCOUNT(i->pkt) + + GLDNS_ARCOUNT(i->pkt) ? SECTION_ADDITIONAL + : SECTION_ANY; } /* Utility functions to read rr_type and rr_class from a rr iterator */ diff --git a/src/stub.c b/src/stub.c index 9bc0a455..ed666368 100644 --- a/src/stub.c +++ b/src/stub.c @@ -379,6 +379,7 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport) if (transport == GETDNS_TRANSPORT_TCP) return fd; #elif USE_OSX_TCP_FASTOPEN + (void)transport; sa_endpoints_t endpoints; endpoints.sae_srcif = 0; endpoints.sae_srcaddr = NULL; @@ -394,6 +395,8 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport) } } return fd; +#else + (void)transport; #endif if (connect(fd, (struct sockaddr *)&upstream->addr, upstream->addr_len) == -1) { @@ -678,7 +681,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf) tcp->to_read = 2; /* Packet size */ } read = recv(fd, (void *)tcp->read_pos, tcp->to_read, 0); - if (read == -1) { + if (read < 0) { if (_getdns_EWOULDBLOCK) return STUB_TCP_WOULDBLOCK; else @@ -687,7 +690,7 @@ stub_tcp_read(int fd, getdns_tcp_state *tcp, struct mem_funcs *mf) /* Remote end closed the socket */ /* TODO: Try to reconnect */ return STUB_TCP_ERROR; - } else if (read> tcp->to_read) { + } else if ((size_t)read > tcp->to_read) { return STUB_TCP_ERROR; } tcp->to_read -= read; @@ -795,12 +798,12 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq) (struct sockaddr *)&(netreq->upstream->addr), netreq->upstream->addr_len); #endif - if ((written == -1 && (_getdns_EWOULDBLOCK || + if ((written < 0 && (_getdns_EWOULDBLOCK || /* Add the error case where the connection is in progress which is when a cookie is not available (e.g. when doing the first request to an upstream). We must let the handshake complete since non-blocking. */ _getdns_EINPROGRESS)) || - written < pkt_len + 2) { + (size_t)written < pkt_len + 2) { /* We couldn't write the whole packet. * We have to return with STUB_TCP_AGAIN. diff --git a/src/sync.c b/src/sync.c index d100afb8..bfec94c6 100644 --- a/src/sync.c +++ b/src/sync.c @@ -151,6 +151,7 @@ getdns_sync_cb(getdns_context *context, getdns_callback_type_t callback_type, getdns_dict *response, void *userarg, getdns_transaction_t transaction_id) { getdns_sync_data *data = (getdns_sync_data *)userarg; + (void)context; (void)callback_type; (void)transaction_id; assert(data); diff --git a/src/test/Makefile.in b/src/test/Makefile.in index 797f2e6e..ff4e800f 100644 --- a/src/test/Makefile.in +++ b/src/test/Makefile.in @@ -57,7 +57,8 @@ CHECK_EVENT_PROG=@CHECK_EVENT_PROG@ CHECK_EV_PROG=@CHECK_EV_PROG@ CC=@CC@ -CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ +CFLAGS=-I$(srcdir)/.. -I$(srcdir) -I.. $(cflags) @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS) +WPEDANTICFLAG=@WPEDANTICFLAG@ LDFLAGS=-L.. @LDFLAGS@ LDLIBS=../libgetdns.la @LIBS@ CHECK_LIBS=@CHECK_LIBS@ @@ -85,59 +86,59 @@ PROGRAMS=tests_dict tests_list tests_namespaces tests_stub_async tests_stub_sync .SUFFIXES: .c .o .a .lo .h .c.o: - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@ .c.lo: - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $< -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $< -o $@ default: all all: $(PROGRAMS) jsmn.lo: - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -DJSMN_GETDNS -c $(srcdir)/jsmn/jsmn.c -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -DJSMN_GETDNS -c $(srcdir)/jsmn/jsmn.c -o $@ $(ALL_OBJS): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -c $(srcdir)/$(@:.lo=.c) -o $@ $(NON_C99_OBJS): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -c $(srcdir)/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) $(WPEDANTICFLAG) -D_POSIX_C_SOURCE=200112L -D_XOPEN_SOURCE=600 -c $(srcdir)/$(@:.lo=.c) -o $@ tests_dict: tests_dict.lo testmessages.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_dict.lo testmessages.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_dict.lo testmessages.lo tests_list: tests_list.lo testmessages.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.lo testmessages.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_list.lo testmessages.lo tests_namespaces: tests_namespaces.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_namespaces.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_namespaces.lo tests_stub_async: tests_stub_async.lo testmessages.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.lo testmessages.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_async.lo testmessages.lo tests_stub_sync: tests_stub_sync.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ tests_stub_sync.lo check_getdns_common: check_getdns_common.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) -o $@ check_getdns_common.lo check_getdns: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo + $(LIBTOOL) --tag=CC --mode=link $(CC) $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_selectloop.lo check_getdns_event: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo ../libgetdns_ext_event.la - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libevent.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_event.la $(EXTENSION_LIBEVENT_LDFLAGS) $(EXTENSION_LIBEVENT_EXT_LIBS) check_getdns_uv: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo ../libgetdns_ext_uv.la - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libuv.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_uv.la $(EXTENSION_LIBUV_LDFLAGS) $(EXTENSION_LIBUV_EXT_LIBS) check_getdns_ev: check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo ../libgetdns_ext_ev.la - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_CFLAGS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ check_getdns.lo check_getdns_common.lo check_getdns_context_set_timeout.lo check_getdns_transport.lo check_getdns_libev.lo $(LDFLAGS) $(LDLIBS) $(CHECK_LIBS) ../libgetdns_ext_ev.la $(EXTENSION_LIBEV_LDFLAGS) $(EXTENSION_LIBEV_EXT_LIBS) getdns_query: getdns_query.lo $(DECOMPOSED_OBJS) - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ getdns_query.lo $(DECOMPOSED_OBJS) $(LDFLAGS) $(LDLIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ getdns_query.lo $(DECOMPOSED_OBJS) $(LDFLAGS) $(LDLIBS) scratchpad: scratchpad.lo - $(LIBTOOL) --tag=CC --mode=link $(CC) $(CFLAGS) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS) + $(LIBTOOL) --tag=CC --mode=link $(CC) -o $@ scratchpad.lo $(LDFLAGS) $(LDLIBS) scratchpad.lo: scratchpad.c 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_address.h b/src/test/check_getdns_address.h index 65f76b8b..2c59d992 100644 --- a/src/test/check_getdns_address.h +++ b/src/test/check_getdns_address.h @@ -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; diff --git a/src/test/check_getdns_cancel_callback.h b/src/test/check_getdns_cancel_callback.h index 7ad31b46..facf31bc 100644 --- a/src/test/check_getdns_cancel_callback.h +++ b/src/test/check_getdns_cancel_callback.h @@ -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; @@ -451,6 +457,8 @@ void *userarg, getdns_transaction_t transaction_id) { + (void)context; (void)response; (void)userarg; + callback_called++; if(callback_type == GETDNS_CALLBACK_CANCEL) @@ -483,6 +491,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..20310f93 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); @@ -338,7 +339,8 @@ 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; /* * 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_common.h b/src/test/check_getdns_common.h index e2d77f44..6fb3b555 100644 --- a/src/test/check_getdns_common.h +++ b/src/test/check_getdns_common.h @@ -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 diff --git a/src/test/check_getdns_context_destroy.h b/src/test/check_getdns_context_destroy.h index 52b28456..65a0a8c3 100644 --- a/src/test/check_getdns_context_destroy.h +++ b/src/test/check_getdns_context_destroy.h @@ -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; @@ -267,6 +271,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_general.h b/src/test/check_getdns_general.h index 6a19bdfb..f073cd86 100644 --- a/src/test/check_getdns_general.h +++ b/src/test/check_getdns_general.h @@ -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; diff --git a/src/test/check_getdns_hostname.h b/src/test/check_getdns_hostname.h index 461ad373..7193fec9 100644 --- a/src/test/check_getdns_hostname.h +++ b/src/test/check_getdns_hostname.h @@ -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; 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_service.h b/src/test/check_getdns_service.h index c9545c0c..c93cab0e 100644 --- a/src/test/check_getdns_service.h +++ b/src/test/check_getdns_service.h @@ -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; 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/getdns_context_set_listen_addresses.c b/src/test/getdns_context_set_listen_addresses.c index 9246b640..03ac6340 100644 --- a/src/test/getdns_context_set_listen_addresses.c +++ b/src/test/getdns_context_set_listen_addresses.c @@ -101,9 +101,9 @@ typedef struct tcp_connection { getdns_eventloop_event event; uint8_t *read_buf; - size_t read_buf_len; + ssize_t read_buf_len; uint8_t *read_pos; - size_t to_read; + ssize_t to_read; tcp_to_write *to_write; size_t to_answer; @@ -331,7 +331,7 @@ static void tcp_read_cb(void *userarg) (void) loop->vmt->schedule(loop, conn->fd, DOWNSTREAM_IDLE_TIMEOUT, &conn->event); - if ((bytes_read = read(conn->fd, conn->read_pos, conn->to_read)) == -1) { + if ((bytes_read = read(conn->fd, conn->read_pos, conn->to_read)) < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK) return; /* Come back to do the read later */ @@ -705,9 +705,9 @@ static getdns_return_t add_listeners(listen_set *set) break; if (setsockopt(l->fd, SOL_SOCKET, SO_REUSEADDR, - &enable, sizeof(int)) < 0) + &enable, sizeof(int)) < 0) { ; /* Ignore */ - + } if (bind(l->fd, (struct sockaddr *)&l->addr, l->addr_len) == -1) /* IO error */ diff --git a/src/test/getdns_query.c b/src/test/getdns_query.c index 5c98d8f9..8230b7ef 100644 --- a/src/test/getdns_query.c +++ b/src/test/getdns_query.c @@ -122,8 +122,8 @@ static int get_rrclass(const char *t) } static getdns_return_t -fill_transport_list(getdns_context *context, char *transport_list_str, - getdns_transport_list_t *transports, size_t *transport_count) +fill_transport_list(char *transport_list_str, + getdns_transport_list_t *transports, size_t *transport_count) { size_t max_transports = *transport_count; *transport_count = 0; @@ -334,6 +334,7 @@ void callback(getdns_context *context, getdns_callback_type_t callback_type, getdns_dict *response, void *userarg, getdns_transaction_t trans_id) { char *response_str; + (void)context; (void)userarg; /* This is a callback with data */; if (response && !quiet && (response_str = json ? @@ -475,7 +476,8 @@ static void parse_config(const char *config_str) getdns_return_t parse_args(int argc, char **argv) { getdns_return_t r = GETDNS_RETURN_GOOD; - size_t i, j, klass; + size_t j; + int i, klass; char *arg, *c, *endptr; int t, print_api_info = 0, print_trust_anchors = 0; getdns_list *upstream_list = NULL; @@ -622,7 +624,7 @@ getdns_return_t parse_args(int argc, char **argv) } rewind(fh); if (fread(config_file, 1, config_file_sz, fh) - != config_file_sz) { + != (size_t)config_file_sz) { fprintf(stderr, "An error occurred whil" "e reading \"%s\": %s\n",argv[i], strerror(errno)); @@ -913,7 +915,7 @@ getdns_return_t parse_args(int argc, char **argv) } getdns_transport_list_t transports[10]; size_t transport_count = sizeof(transports); - if ((r = fill_transport_list(context, argv[i], transports, &transport_count)) || + if ((r = fill_transport_list(argv[i], transports, &transport_count)) || (r = getdns_context_set_dns_transport_list(context, transport_count, transports))){ fprintf(stderr, "Could not set transports\n"); @@ -983,13 +985,13 @@ next: ; if (pubkey_pinset && upstream_count) { getdns_dict *upstream; /* apply the accumulated pubkey pinset to all upstreams: */ - for (i = 0; i < upstream_count; i++) { - if (r = getdns_list_get_dict(upstream_list, i, &upstream), r) { - fprintf(stderr, "Failed to get upstream "PRIsz" when adding pinset\n", i); + for (j = 0; j < upstream_count; j++) { + if (r = getdns_list_get_dict(upstream_list, j, &upstream), r) { + fprintf(stderr, "Failed to get upstream "PRIsz" when adding pinset\n", j); return r; } if (r = getdns_dict_set_list(upstream, "tls_pubkey_pinset", pubkey_pinset), r) { - fprintf(stderr, "Failed to set pubkey pinset on upstream "PRIsz"\n", i); + fprintf(stderr, "Failed to set pubkey pinset on upstream "PRIsz"\n", j); return r; } } @@ -1282,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/test/getdns_str2dict.c b/src/test/getdns_str2dict.c index 28323d9d..3c894ee6 100644 --- a/src/test/getdns_str2dict.c +++ b/src/test/getdns_str2dict.c @@ -33,6 +33,7 @@ #include "list.h" /* For _getdns_list_create_from_mf() */ #include "dict.h" /* For _getdns_dict_create_from_mf() */ #include /* For bsearch */ +#include /* For isspace */ static struct mem_funcs _getdns_plain_mem_funcs = { MF_PLAIN, .mf.pln = { malloc, realloc, free } @@ -102,7 +103,7 @@ static int _gldns_b64_pton(char const *src, uint8_t *target, size_t targsize) } static getdns_dict * -_getdns_ipaddr_dict_mf(struct mem_funcs *mf, char *ipstr) +_getdns_ipaddr_dict_mf(struct mem_funcs *mf, const char *ipstr) { getdns_dict *r = _getdns_dict_create_with_mf(mf); char *s = strchr(ipstr, '%'), *scope_id_str = ""; @@ -223,7 +224,7 @@ static int _jsmn_get_ipdict(struct mem_funcs *mf, const char *js, jsmntok_t *t, char value_str[3072]; int size = t->end - t->start; - if (size <= 0 || size >= sizeof(value_str)) + if (size <= 0 || size >= (int)sizeof(value_str)) return 0; (void) memcpy(value_str, js + t->start, size); @@ -236,7 +237,8 @@ static int _jsmn_get_ipdict(struct mem_funcs *mf, const char *js, jsmntok_t *t, static int _jsmn_get_data(struct mem_funcs *mf, const char *js, jsmntok_t *t, getdns_bindata **value) { - size_t i, j; + int i; + size_t j; uint8_t h, l; if ((t->end - t->start) < 4 || (t->end - t->start) % 2 == 1 || @@ -272,13 +274,13 @@ static int _jsmn_get_data(struct mem_funcs *mf, const char *js, jsmntok_t *t, return 1; } -static int _jsmn_get_dname(struct mem_funcs *mf, const char *js, jsmntok_t *t, +static int _jsmn_get_dname(const char *js, jsmntok_t *t, getdns_bindata **value) { char value_str[1025]; int size = t->end - t->start; - if (size <= 0 || size >= sizeof(value_str) || js[t->end - 1] != '.') + if (size <= 0 || size >= (int)sizeof(value_str) || js[t->end - 1] != '.') return 0; (void) memcpy(value_str, js + t->start, size); @@ -294,7 +296,7 @@ static int _jsmn_get_ipv4(struct mem_funcs *mf, const char *js, jsmntok_t *t, int size = t->end - t->start; uint8_t buf[4]; - if (size <= 0 || size >= sizeof(value_str)) + if (size <= 0 || size >= (int)sizeof(value_str)) return 0; (void) memcpy(value_str, js + t->start, size); @@ -324,7 +326,7 @@ static int _jsmn_get_ipv6(struct mem_funcs *mf, const char *js, jsmntok_t *t, int size = t->end - t->start; uint8_t buf[16]; - if (size <= 0 || size >= sizeof(value_str)) + if (size <= 0 || size >= (int)sizeof(value_str)) return 0; (void) memcpy(value_str, js + t->start, size); @@ -347,14 +349,13 @@ static int _jsmn_get_ipv6(struct mem_funcs *mf, const char *js, jsmntok_t *t, return 0; } -static int _jsmn_get_int(struct mem_funcs *mf, const char *js, jsmntok_t *t, - uint32_t *value) +static int _jsmn_get_int(const char *js, jsmntok_t *t, uint32_t *value) { char value_str[11]; int size = t->end - t->start; char *endptr; - if (size <= 0 || size >= sizeof(value_str)) + if (size <= 0 || size >= (int)sizeof(value_str)) return 0; (void) memcpy(value_str, js + t->start, size); @@ -366,13 +367,12 @@ static int _jsmn_get_int(struct mem_funcs *mf, const char *js, jsmntok_t *t, static int _getdns_get_const_name_info(const char *name, uint32_t *code); -static int _jsmn_get_const(struct mem_funcs *mf, const char *js, jsmntok_t *t, - uint32_t *value) +static int _jsmn_get_const(const char *js, jsmntok_t *t, uint32_t *value) { char value_str[80]; int size = t->end - t->start; - if (size <= 0 || size >= sizeof(value_str)) + if (size <= 0 || size >= (int)sizeof(value_str)) return 0; (void) memcpy(value_str, js + t->start, size); @@ -406,7 +406,8 @@ static int _jsmn_get_item(struct mem_funcs *mf, const char *js, jsmntok_t *t, static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t, size_t count, getdns_dict *dict, getdns_return_t *r) { - size_t i, j = 1; + int i; + size_t j = 1; char key_spc[1024], *key = NULL; getdns_item child_item; @@ -426,7 +427,7 @@ static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t, *r = GETDNS_RETURN_GENERIC_ERROR; /* range error */ break; } - if (t[j].end - t[j].start < sizeof(key_spc)) + if (t[j].end - t[j].start < (int)sizeof(key_spc)) key = key_spc; else if (!(key = GETDNS_XMALLOC( @@ -484,7 +485,8 @@ static int _jsmn_get_dict(struct mem_funcs *mf, const char *js, jsmntok_t *t, static int _jsmn_get_list(struct mem_funcs *mf, const char *js, jsmntok_t *t, size_t count, getdns_list *list, getdns_return_t *r) { - size_t i, j = 1, index = 0; + int i; + size_t j = 1, index = 0; getdns_item child_item; if (t->size <= 0) @@ -563,13 +565,13 @@ static int _jsmn_get_item(struct mem_funcs *mf, const char *js, jsmntok_t *t, *r = GETDNS_RETURN_GENERIC_ERROR; break; - } else if (_jsmn_get_int(mf, js, t, &item->data.n) - || _jsmn_get_const(mf, js, t, &item->data.n)) { + } else if (_jsmn_get_int(js, t, &item->data.n) + || _jsmn_get_const(js, t, &item->data.n)) { item->dtype = t_int; } else if (_jsmn_get_data(mf, js, t, &item->data.bindata) - || _jsmn_get_dname(mf, js, t, &item->data.bindata) + || _jsmn_get_dname(js, t, &item->data.bindata) || _jsmn_get_ipv4(mf, js, t, &item->data.bindata) || _jsmn_get_ipv6(mf, js, t, &item->data.bindata)) @@ -645,6 +647,17 @@ getdns_str2dict(const char *str, getdns_dict **dict) getdns_item item; getdns_return_t r; + while (*str && isspace(*str)) + str++; + + if (*str != '{') { + getdns_dict *dict_r = _getdns_ipaddr_dict_mf( + &_getdns_plain_mem_funcs, str); + if (dict_r) { + *dict = dict_r; + return GETDNS_RETURN_GOOD; + } + } if ((r = _getdns_str2item_mf(&_getdns_plain_mem_funcs, str, &item))) return r; 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); diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.test b/src/test/tpkg/100-compile.tpkg/100-compile.test index e527192b..819c1bb3 100644 --- a/src/test/tpkg/100-compile.tpkg/100-compile.test +++ b/src/test/tpkg/100-compile.tpkg/100-compile.test @@ -5,4 +5,4 @@ [ -f .tpkg.var.test ] && source .tpkg.var.test cd "${BUILDDIR}/build" -make +make XTRA_CFLAGS='-Werror' diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test index 369379c4..144fea4b 100644 --- a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.test @@ -5,4 +5,4 @@ [ -f .tpkg.var.test ] && source .tpkg.var.test cd "${BUILDDIR}/build-stub-only" -make +make XTRA_CFLAGS='-Werror' diff --git a/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test b/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test index 83ade30b..5da09cd9 100644 --- a/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test +++ b/src/test/tpkg/300-event-loops-configure.tpkg/300-event-loops-configure.test @@ -7,10 +7,10 @@ rm -fr "${BUILDDIR}/build-event-loops" mkdir "${BUILDDIR}/build-event-loops" cd "${BUILDDIR}/build-event-loops" -"${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev --with-libuv \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libev \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent --with-libuv \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev --with-libuv \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libevent \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libev \ - || "${SRCROOT}/configure" $* --enable-all-drafts --enable-all-debugging --with-getdns_query --with-libuv +"${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev --with-libuv \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libuv \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libev --with-libuv \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libevent \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libev \ + || "${SRCROOT}/configure" $* --enable-all-drafts --with-getdns_query --with-libuv diff --git a/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.dsc b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.dsc new file mode 100644 index 00000000..82cbdb8c --- /dev/null +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.dsc @@ -0,0 +1,16 @@ +BaseName: 315-event-loops-compile +Version: 1.0 +Description: Compile +CreationDate: do 8 dec 2016 23:38:18 CET +Maintainer: Willem Toorop +Category: +Component: +CmdDepends: +Depends: 300-event-loops-configure.tpkg +Help: +Pre: 315-event-loops-compile.pre +Post: 315-event-loops-compile.post +Test: 315-event-loops-compile.test +AuxFiles: +Passed: +Failure: diff --git a/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post new file mode 100644 index 00000000..4d5f4293 --- /dev/null +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post @@ -0,0 +1,20 @@ +# #-- 315-event-loops-compile.post --# +# source the master var file when it's there +if [ -f ../.tpkg.var.master ] +then + source ../.tpkg.var.master +else + ( + cd .. + [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \ + && sh "${TPKG_SRCDIR}/setup-env.sh" + ) && source ../.tpkg.var.master +fi +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +for f in `cat restore-srcdir-configure-settings` +do + mv "${SRCROOT}/${f}.build-event-loops" "${SRCROOT}/${f}" +done + diff --git a/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre new file mode 100644 index 00000000..4ec46299 --- /dev/null +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre @@ -0,0 +1,24 @@ +# #-- 315-event-loops-compile.pre--# +# source the master var file when it's there +if [ -f ../.tpkg.var.master ] +then + source ../.tpkg.var.master +else + ( + cd .. + [ -f "${TPKG_SRCDIR}/setup-env.sh" ] \ + && sh "${TPKG_SRCDIR}/setup-env.sh" + ) && source ../.tpkg.var.master +fi +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +echo "" > restore-srcdir-configure-settings +for f in `grep 'CONFIG_[FH][IE][LA][ED][SE]' "${SRCROOT}/configure.ac" | sed -e 's/^.*(\[//g' -e 's/\])//g'` +do + if [ -f "${SRCROOT}/$f" ] + then + mv "${SRCROOT}/${f}" "${SRCROOT}/${f}.build-event-loops" && \ + echo "$f" >> restore-srcdir-configure-settings + fi +done diff --git a/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test new file mode 100644 index 00000000..7a420026 --- /dev/null +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test @@ -0,0 +1,8 @@ +# #-- 315-event-loops-compile.test --# +# source the master var file when it's there +[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master +# use .tpkg.var.test for in test variable passing +[ -f .tpkg.var.test ] && source .tpkg.var.test + +cd "${BUILDDIR}/build-event-loops" +make XTRA_CFLAGS='-Werror' diff --git a/src/test/tpkg/320-event-loops-compile.tpkg/320-event-loops-compile.test b/src/test/tpkg/320-event-loops-compile.tpkg/320-event-loops-compile.test index 055f8f9b..aa19d023 100644 --- a/src/test/tpkg/320-event-loops-compile.tpkg/320-event-loops-compile.test +++ b/src/test/tpkg/320-event-loops-compile.tpkg/320-event-loops-compile.test @@ -5,4 +5,5 @@ [ -f .tpkg.var.test ] && source .tpkg.var.test cd "${BUILDDIR}/build-event-loops" +make clean make diff --git a/src/types-internal.h b/src/types-internal.h index bf7bfd7e..37588e7a 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -110,7 +110,7 @@ struct getdns_upstream; #define GETDNS_STR_KEY_NSCOUNT "nscount" #define GETDNS_STR_KEY_ARCOUNT "arcount" -#define TIMEOUT_FOREVER ((int64_t)-1) +#define TIMEOUT_FOREVER ((uint64_t)0xFFFFFFFFFFFFFFFF) #define ASSERT_UNREACHABLE 0 #define GETDNS_TRANSPORTS_MAX 3 @@ -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 ddf59c68..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) { @@ -353,6 +353,7 @@ static int my_timer_del(struct ub_event* ev) static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv) { + (void)ub_ev; (void)tv; /* Only unbound daaemon workers use signals */ DEBUG_SCHED("UB_LOOP ERROR: signal_add()\n"); return -1; @@ -360,6 +361,7 @@ static int my_signal_add(struct ub_event* ub_ev, struct timeval* tv) static int my_signal_del(struct ub_event* ub_ev) { + (void)ub_ev; /* Only unbound daaemon workers use signals */ DEBUG_SCHED("UB_LOOP ERROR: signal_del()\n"); return -1; @@ -412,7 +414,7 @@ static struct ub_event* my_event_new(struct ub_event_base* base, int fd, ev->added = 0; ev->fd = fd; ev->bits = bits; - ev->timeout = (uint64_t)-1; + ev->timeout = TIMEOUT_FOREVER; ev->cb = cb; ev->arg = arg; #ifdef USE_WINSOCK diff --git a/src/util-internal.c b/src/util-internal.c index 18ca27bf..99727a2f 100644 --- a/src/util-internal.c +++ b/src/util-internal.c @@ -890,7 +890,7 @@ static int _srv_cmp(const void *a, const void *b) static void _rfc2782_sort(_srv_rr *start, _srv_rr *end) { - unsigned int running_sum, n; + uint32_t running_sum, n; _srv_rr *i, *j, swap; /* First move all SRVs with weight 0 to the beginning of the list */ @@ -1253,6 +1253,8 @@ getdns_return_t getdns_apply_network_result(getdns_network_req* netreq, int rcode, void *pkt, int pkt_len, int sec, char* why_bogus) { + (void)why_bogus; + netreq->dnssec_status = sec == 0 ? GETDNS_DNSSEC_INSECURE : sec == 2 ? GETDNS_DNSSEC_SECURE : GETDNS_DNSSEC_BOGUS;