From 0d13ae6d72e59e42b6905f98b57089e31817e7fd Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Sun, 4 Dec 2016 17:26:38 -0800 Subject: [PATCH 01/14] Fixing several issues in function set_os_defaults_windows that prevent working on Windows. --- src/context.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/context.c b/src/context.c index 8893191e..010b1685 100644 --- a/src/context.c +++ b/src/context.c @@ -929,6 +929,7 @@ set_os_defaults_windows(struct getdns_context *context) getdns_upstream *upstream; size_t length; int s; + uint32_t info_err = 0; if (context->fchg_resolvconf == NULL) { context->fchg_resolvconf = @@ -961,15 +962,16 @@ set_os_defaults_windows(struct getdns_context *context) if (info == NULL) return GETDNS_RETURN_GENERIC_ERROR; - if (GetNetworkParams(info, &buflen) == ERROR_BUFFER_OVERFLOW) { + if ((info_err = GetNetworkParams(info, &buflen)) == ERROR_BUFFER_OVERFLOW) { free(info); info = (FIXED_INFO *)malloc(buflen); if (info == NULL) return GETDNS_RETURN_GENERIC_ERROR; + info_err = GetNetworkParams(info, &buflen); } - if (GetNetworkParams(info, &buflen) == NO_ERROR) { - ptr = info->DnsServerList.Next; + if (info_err == NO_ERROR) { + ptr = &info->DnsServerList; *domain = 0; while (ptr) { for (size_t i = 0; i < GETDNS_UPSTREAM_TRANSPORTS; i++) { @@ -986,11 +988,12 @@ set_os_defaults_windows(struct getdns_context *context) freeaddrinfo(result); } ptr = ptr->Next; - } - free(info); } + if (info != NULL) + free(info); + suffix = getdns_list_create_with_context(context); if (get_dns_suffix_windows(suffix, domain)) { From dee33f53b65e03dd3d31da781863867e9d03bb7a Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Mon, 5 Dec 2016 11:38:59 -0800 Subject: [PATCH 02/14] Reminder of changes required by the Windows port. This solves the issues 228, 229, 230 and 232. --- src/compat/arc4random.c | 11 +++++ src/compat/gettimeofday.c | 73 +++++++++++++++++++++++++++++++ src/extension/default_eventloop.c | 16 +++---- src/stub.c | 41 +++++++++++++++-- 4 files changed, 129 insertions(+), 12 deletions(-) create mode 100644 src/compat/gettimeofday.c diff --git a/src/compat/arc4random.c b/src/compat/arc4random.c index 2c78818f..bd5f6e3a 100644 --- a/src/compat/arc4random.c +++ b/src/compat/arc4random.c @@ -38,6 +38,9 @@ #ifndef GETDNS_ON_WINDOWS #include #endif +#if defined(GETDNS_ON_WINDOWS) && !defined(MAP_INHERIT_ZERO) +#define explicit_bzero(rnd, rnd_size) memset(rnd, 0, rnd_size) +#endif #define KEYSTREAM_ONLY #include "chacha_private.h" @@ -136,7 +139,15 @@ _rs_stir_if_needed(size_t len) { #ifndef MAP_INHERIT_ZERO static pid_t _rs_pid = 0; +#ifdef GETDNS_ON_WINDOWS + /* + * TODO: if compiling for the Windows Runtime, use GetCurrentProcessId(), + * but this requires linking with kernel32.lib + */ + pid_t pid = _getpid(); +#else pid_t pid = getpid(); +#endif /* If a system lacks MAP_INHERIT_ZERO, resort to getpid() */ if (_rs_pid == 0 || _rs_pid != pid) { diff --git a/src/compat/gettimeofday.c b/src/compat/gettimeofday.c new file mode 100644 index 00000000..d8fe91bc --- /dev/null +++ b/src/compat/gettimeofday.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2016 Christian Huitema + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + /* + * Numerous places in the code make reference to the Unix/Linux + * "gettimeofday()" function, which is not available in the standard + * windows libraries. This code provides a compatible implementation. + */ +#include "config.h" + +#ifdef GETDNS_ON_WINDOWS +int gettimeofday(struct timeval* tv, struct timezone* tz) +{ + FILETIME ft; + uint64_t now = 0; + + /* + * The GetSystemTimeAsFileTime API returns the number + * of 100-nanosecond intervals since January 1, 1601 (UTC), + * in FILETIME format. + */ + GetSystemTimeAsFileTime(&ft); + + /* + * Convert to plain 64 bit format, without making + * assumptions about the FILETIME structure alignment. + */ + now |= ft.dwHighDateTime; + now <<= 32; + now |= ft.dwLowDateTime; + /* + * Convert units from 100ns to 1us + */ + now /= 10; + /* + * Account for microseconds elapsed between 1601 and 1970. + */ + now -= 11644473600000000ULL; + + if (tv != NULL) + { + uint64_t sec = now / 1000000; + uint64_t usec = now % 1000000; + + tv->tv_sec = (long)sec; + tv->tv_usec = (long)usec; + } + + if (tz != NULL) + { + /* + * TODO: implement a timezone retrieval function. + * Not urgent, since the GetDNS code always set this parameter to NULL. + */ + return -1; + } + + return 0; +} +#endif /* GETDNS_ON_WINDOWS */ \ No newline at end of file diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index 10efff59..2f9856dd 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -25,6 +25,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "Config.h" + #include "extension/default_eventloop.h" #include "debug.h" @@ -32,7 +34,7 @@ static uint64_t get_now_plus(uint64_t amount) { struct timeval tv; uint64_t now; - + if (gettimeofday(&tv, NULL)) { perror("gettimeofday() failed"); exit(EXIT_FAILURE); @@ -81,8 +83,7 @@ default_eventloop_schedule(getdns_eventloop *loop, #endif default_loop->fd_events[fd] = event; default_loop->fd_timeout_times[fd] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) fd + 1; - + event->ev = (void *)(intptr_t)(fd + 1); DEBUG_SCHED( "scheduled read/write at %d\n", fd); return GETDNS_RETURN_GOOD; } @@ -101,9 +102,8 @@ default_eventloop_schedule(getdns_eventloop *loop, for (i = 0; i < MAX_TIMEOUTS; i++) { if (default_loop->timeout_events[i] == NULL) { default_loop->timeout_events[i] = event; - default_loop->timeout_times[i] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) i + 1; - + default_loop->timeout_times[i] = get_now_plus(timeout); + event->ev = (void *)(intptr_t)(i + 1); DEBUG_SCHED( "scheduled timeout at %d\n", (int)i); return GETDNS_RETURN_GOOD; } @@ -219,8 +219,8 @@ default_eventloop_run_once(getdns_eventloop *loop, int blocking) tv.tv_sec = 0; tv.tv_usec = 0; } else { - tv.tv_sec = (timeout - now) / 1000000; - tv.tv_usec = (timeout - now) % 1000000; + tv.tv_sec = (long)((timeout - now) / 1000000); + tv.tv_usec = (long)((timeout - now) % 1000000); } if (select(max_fd + 1, &readfds, &writefds, NULL, (timeout == ((uint64_t)-1) ? NULL : &tv)) < 0) { diff --git a/src/stub.c b/src/stub.c index 4aa14dae..8232e288 100644 --- a/src/stub.c +++ b/src/stub.c @@ -399,7 +399,11 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport) upstream->addr_len) == -1) { if (_getdns_EINPROGRESS || _getdns_EWOULDBLOCK) return fd; +#ifdef USE_WINSOCK + closesocket(fd); +#else close(fd); +#endif return -1; } return fd; @@ -541,7 +545,13 @@ void _getdns_cancel_stub_request(getdns_network_req *netreq) { stub_cleanup(netreq); - if (netreq->fd >= 0) close(netreq->fd); + if (netreq->fd >= 0) { +#ifdef USE_WINSOCK + closesocket(netreq->fd); +#else + close(netreq->fd); +#endif + } } /* May be needed in future for better UDP error handling?*/ @@ -564,7 +574,12 @@ stub_timeout_cb(void *userarg) STUB_DEBUG_CLEANUP, __FUNCTION__, netreq); stub_next_upstream(netreq); stub_cleanup(netreq); - if (netreq->fd >= 0) close(netreq->fd); + if (netreq->fd >= 0) +#ifdef USE_WINSOCK + closesocket(netreq->fd); +#else + close(netreq->fd); +#endif netreq->state = NET_REQ_TIMED_OUT; if (netreq->owner->user_callback) { netreq->debug_end_time = _getdns_get_time_as_uintt64(); @@ -807,8 +822,13 @@ stub_tcp_write(int fd, getdns_tcp_state *tcp, getdns_network_req *netreq) /* Coming back from an earlier unfinished write or handshake. * Try to send remaining data */ +#ifdef USE_WINSOCK + written = send(fd, tcp->write_buf + tcp->written, + tcp->write_buf_len - tcp->written, 0); +#else written = write(fd, tcp->write_buf + tcp->written, tcp->write_buf_len - tcp->written); +#endif if (written == -1) { if (_getdns_EWOULDBLOCK) return STUB_TCP_WOULDBLOCK; @@ -1257,10 +1277,10 @@ stub_tls_write(getdns_upstream *upstream, getdns_tcp_state *tcp, static uint64_t _getdns_get_time_as_uintt64() { - + struct timeval tv; uint64_t now; - + if (gettimeofday(&tv, NULL)) { return 0; } @@ -1268,6 +1288,7 @@ _getdns_get_time_as_uintt64() { return now; } + /**************************/ /* UDP callback functions */ /**************************/ @@ -1305,7 +1326,11 @@ stub_udp_read_cb(void *userarg) upstream, netreq->response, read)) return; /* Client cookie didn't match? */ +#ifdef USE_WINSOCK + closesocket(netreq->fd); +#else close(netreq->fd); +#endif while (GLDNS_TC_WIRE(netreq->response)) { DEBUG_STUB("%s %-35s: MSG: %p TC bit set in response \n", STUB_DEBUG_READ, __FUNCTION__, netreq); @@ -1369,7 +1394,11 @@ stub_udp_write_cb(void *userarg) netreq->fd, (const void *)netreq->query, pkt_len, 0, (struct sockaddr *)&netreq->upstream->addr, netreq->upstream->addr_len)) { +#ifdef USE_WINSOCK + closesocket(netreq->fd); +#else close(netreq->fd); +#endif return; } GETDNS_SCHEDULE_EVENT( @@ -1706,7 +1735,11 @@ upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport, if (fd == -1) return -1; upstream->tls_obj = tls_create_object(dnsreq, fd, upstream); if (upstream->tls_obj == NULL) { +#ifdef USE_WINSOCK + closesocket(fd); +#else close(fd); +#endif return -1; } From 702fe1f5d975c0ccbc7b35694cc64d6dd1ff60a0 Mon Sep 17 00:00:00 2001 From: huitema Date: Tue, 6 Dec 2016 12:32:44 -0800 Subject: [PATCH 03/14] Update default_eventloop.c --- src/extension/default_eventloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index 2f9856dd..b6ad5586 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -25,7 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "Config.h" +#include "config.h" #include "extension/default_eventloop.h" #include "debug.h" From 50b064a292404c77d04ea714a597f6e3a05f36b0 Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Wed, 7 Dec 2016 15:40:24 -0800 Subject: [PATCH 04/14] Fixing potential clipping of idle_timeout value in call to upstream_reschedule_events --- src/stub.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/stub.c b/src/stub.c index 8232e288..9bc0a455 100644 --- a/src/stub.c +++ b/src/stub.c @@ -84,7 +84,7 @@ static void upstream_idle_timeout_cb(void *userarg); static void upstream_schedule_netreq(getdns_upstream *upstream, getdns_network_req *netreq); static void upstream_reschedule_events(getdns_upstream *upstream, - size_t idle_timeout); + uint64_t idle_timeout); static int upstream_connect(getdns_upstream *upstream, getdns_transport_list_t transport, getdns_dns_req *dnsreq); @@ -1816,7 +1816,7 @@ fallback_on_write(getdns_network_req *netreq) } static void -upstream_reschedule_events(getdns_upstream *upstream, size_t idle_timeout) { +upstream_reschedule_events(getdns_upstream *upstream, uint64_t idle_timeout) { DEBUG_STUB("%s %-35s: FD: %d \n", STUB_DEBUG_SCHEDULE, __FUNCTION__, upstream->fd); From 26eaf255c5a50e07cee5bd96e417eadd93fb06ba Mon Sep 17 00:00:00 2001 From: Christian Huitema Date: Thu, 8 Dec 2016 12:37:35 -0800 Subject: [PATCH 05/14] Fixing the bulk of the compilation warnings in the GetDNS code --- src/compat/arc4random_uniform.c | 2 +- src/context.c | 20 ++++++++++++++++---- src/convert.c | 12 ++++++++++-- src/dict.c | 2 +- src/dnssec.c | 8 ++++---- src/general.c | 2 +- src/list.c | 2 +- src/request-internal.c | 12 ++++++------ src/rr-dict.c | 4 ++-- src/rr-iter.c | 8 ++++---- src/rr-iter.h | 20 ++++++++++---------- src/util-internal.c | 8 +++++--- 12 files changed, 61 insertions(+), 39 deletions(-) diff --git a/src/compat/arc4random_uniform.c b/src/compat/arc4random_uniform.c index 154260eb..c03c2c9b 100644 --- a/src/compat/arc4random_uniform.c +++ b/src/compat/arc4random_uniform.c @@ -39,7 +39,7 @@ arc4random_uniform(uint32_t upper_bound) return 0; /* 2**32 % x == (2**32 - x) % x */ - min = -upper_bound % upper_bound; + min = ((uint32_t)(-(int32_t)upper_bound)) % upper_bound; /* * This could theoretically loop forever but each retry has diff --git a/src/context.c b/src/context.c index 010b1685..ebe45ccb 100644 --- a/src/context.c +++ b/src/context.c @@ -661,7 +661,13 @@ _getdns_upstreams_dereference(getdns_upstreams *upstreams) SSL_free(upstream->tls_obj); } if (upstream->fd != -1) + { +#ifdef USE_WINSOCK + closesocket(upstream->fd); +#else close(upstream->fd); +#endif + } while (pin) { sha256_pin_t *nextpin = pin->next; GETDNS_FREE(upstreams->mf, pin); @@ -707,12 +713,18 @@ _getdns_upstream_shutdown(getdns_upstream *upstream) upstream->tls_obj = NULL; } if (fd != -1) + { +#ifdef USE_WINSOCK + closesocket(fd); +#else close(fd); +#endif + } } static int tls_is_in_transports_list(getdns_context *context) { - for (int i=0; i< context->dns_transport_count;i++) { + for (size_t i=0; i< context->dns_transport_count;i++) { if (context->dns_transports[i] == GETDNS_TRANSPORT_TLS) return 1; } @@ -761,7 +773,7 @@ static getdns_tsig_info const * const last_tsig_info = const getdns_tsig_info *_getdns_get_tsig_info(getdns_tsig_algo tsig_alg) { - return tsig_alg > n_tsig_infos - 1 + return ((unsigned) tsig_alg > n_tsig_infos - 1) || tsig_info[tsig_alg].alg == GETDNS_NO_TSIG ? NULL : &tsig_info[tsig_alg]; } @@ -2200,7 +2212,7 @@ getdns_context_set_suffix(getdns_context *context, getdns_list *value) if (gldns_str2wire_dname_buf(name, dname, &dname_len)) return GETDNS_RETURN_GENERIC_ERROR; - gldns_buffer_write_u8(&gbuf, dname_len); + gldns_buffer_write_u8(&gbuf, (uint8_t) dname_len); gldns_buffer_write(&gbuf, dname, dname_len); } if (r == GETDNS_RETURN_NO_SUCH_LIST_ITEM) @@ -3377,7 +3389,7 @@ _get_context_settings(getdns_context* context) if (!(list = getdns_list_create_with_context(context))) goto error; - for (i = 0; i < context->namespace_count; ++i) { + for (i = 0; (int) i < context->namespace_count; ++i) { if (getdns_list_set_int(list, i, context->namespaces[i])) { getdns_list_destroy(list); diff --git a/src/convert.c b/src/convert.c index 9ce2fa39..353e6abc 100644 --- a/src/convert.c +++ b/src/convert.c @@ -56,6 +56,14 @@ /* 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 +#define STRDUP(x) _strdup(x) +#else +#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) @@ -200,7 +208,7 @@ getdns_display_ip_address(const struct getdns_bindata buff, 256); if (ipStr) { - return strdup(ipStr); + return STRDUP(ipStr); } } else if (bindata_of_ipv4_or_ipv6_address->size == 16) { const char *ipStr = inet_ntop(AF_INET6, @@ -208,7 +216,7 @@ getdns_display_ip_address(const struct getdns_bindata buff, 256); if (ipStr) { - return strdup(ipStr); + return STRDUP(ipStr); } } return NULL; diff --git a/src/dict.c b/src/dict.c index e7294e62..0ab0c784 100644 --- a/src/dict.c +++ b/src/dict.c @@ -65,7 +65,7 @@ static char *_json_ptr_first(const struct mem_funcs *mf, if (!(next_ref = strchr(jptr, '/'))) next_ref = strchr(jptr, '\0'); - if (next_ref - jptr + 1 > first_sz || !first) + if ((unsigned)(next_ref - jptr + 1) > first_sz || !first) first = GETDNS_XMALLOC(*mf, char, next_ref - jptr + 1); for (j = first, k = jptr; k < next_ref; j++, k++) diff --git a/src/dnssec.c b/src/dnssec.c index f567b96b..965ee081 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 || *src + 1 > dst_len) + if (!src || (unsigned)(*src + 1) > dst_len) return NULL; for (i = (*dst++ = *src++); i ; i--) @@ -559,7 +559,7 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf, if (! _dname_is_parent(*label, head->rrset.name)) break; } - if (label - labels > max_labels) { + if ((unsigned)(label - labels) > max_labels) { max_labels = label - labels; max_head = head; } @@ -1210,7 +1210,7 @@ static size_t _rr_uncompressed_rdata_size(_getdns_rrtype_iter *rr) static size_t _rr_rdata_size(_getdns_rrtype_iter *rr) { const _getdns_rr_def *rr_def; - size_t i; + int i; rr_def = _getdns_rr_def_lookup(gldns_read_uint16(rr->rr_i.rr_type)); @@ -1626,7 +1626,7 @@ static int nsec3_iteration_count_high(_getdns_rrtype_iter *dnskey, _getdns_rrset return gldns_read_uint16(rr->rr_i.rr_type + 12) > 150; } -static int check_dates(int32_t now, int32_t skew, int32_t exp, int32_t inc) +static int check_dates(time_t now, int32_t skew, int32_t exp, int32_t inc) { return (exp - inc > 0) && (inc - now < skew) && (now - exp < skew); } diff --git a/src/general.c b/src/general.c index 99e4cff5..3dd7e493 100644 --- a/src/general.c +++ b/src/general.c @@ -420,7 +420,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop, getdns_network_req *netreq, **netreq_p; getdns_dns_req *req; getdns_dict *localnames_response; - size_t i; + int i; if (!context || !name || (!callbackfn && !internal_cb)) return GETDNS_RETURN_INVALID_PARAMETER; diff --git a/src/list.c b/src/list.c index eec2a1c1..486b227b 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) { - int i; + unsigned int i; getdns_return_t retval; if (!dstlist) diff --git a/src/request-internal.c b/src/request-internal.c index 797fde50..69166ace 100644 --- a/src/request-internal.c +++ b/src/request-internal.c @@ -260,10 +260,10 @@ _getdns_network_req_clear_upstream_options(getdns_network_req * req) { size_t pktlen; if (req->opt) { - gldns_write_uint16(req->opt + 9, req->base_query_option_sz); + gldns_write_uint16(req->opt + 9, (uint16_t) req->base_query_option_sz); req->response = req->opt + 11 + req->base_query_option_sz; pktlen = req->response - req->query; - gldns_write_uint16(req->query - 2, pktlen); + gldns_write_uint16(req->query - 2, (uint16_t) pktlen); } } @@ -426,7 +426,7 @@ _getdns_network_req_add_tsig(getdns_network_req *req) gldns_buffer_write_u16(&gbuf, GETDNS_RRCLASS_ANY); /* Class */ gldns_buffer_write_u32(&gbuf, 0); /* TTL */ gldns_buffer_write_u16(&gbuf, - tsig_info->dname_len + 10 + md_len + 6); /* RdLen */ + (uint16_t)(tsig_info->dname_len + 10 + md_len + 6)); /* RdLen */ gldns_buffer_write(&gbuf, tsig_info->dname, tsig_info->dname_len); /* Algorithm Name */ gldns_buffer_write_u48(&gbuf, time(NULL)); /* Time Signed */ @@ -563,7 +563,7 @@ _getdns_network_validate_tsig(getdns_network_req *req) return; gldns_buffer_write_u16(&gbuf, 0); /* Other len */ - other_len = gldns_read_uint16(rdf->pos); + other_len = (uint8_t) gldns_read_uint16(rdf->pos); if (other_len != rdf->nxt - rdf->pos - 2) return; if (other_len) @@ -921,7 +921,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop, request_type, dnssec_extension_set, with_opt, edns_maximum_udp_payload_size, edns_extended_rcode, edns_version, edns_do_bit, - opt_options_size, noptions, options, + (uint16_t) opt_options_size, noptions, options, netreq_sz - sizeof(getdns_network_req), max_query_sz, extensions); @@ -932,7 +932,7 @@ _getdns_dns_req_new(getdns_context *context, getdns_eventloop *loop, dnssec_extension_set, with_opt, edns_maximum_udp_payload_size, edns_extended_rcode, edns_version, edns_do_bit, - opt_options_size, noptions, options, + (uint16_t) opt_options_size, noptions, options, netreq_sz - sizeof(getdns_network_req), max_query_sz, extensions); diff --git a/src/rr-dict.c b/src/rr-dict.c index 76972997..26504512 100644 --- a/src/rr-dict.c +++ b/src/rr-dict.c @@ -429,7 +429,7 @@ hip_hit_2wire( return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; - rdata[0] = value->size; + rdata[0] = (uint8_t) value->size; (void)memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; } @@ -501,7 +501,7 @@ hip_public_key_2wire( return GETDNS_RETURN_NEED_MORE_SPACE; } *rdf_len = value->size; - gldns_write_uint16(rdata + 2, value->size); + gldns_write_uint16(rdata + 2, (uint16_t) value->size); (void)memcpy(rdf, value->data, value->size); return GETDNS_RETURN_GOOD; } diff --git a/src/rr-iter.c b/src/rr-iter.c index 9b332603..7c4d4962 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 && - GLDNS_QDCOUNT(i->pkt) + GLDNS_ANCOUNT(i->pkt) + - GLDNS_NSCOUNT(i->pkt) + GLDNS_ARCOUNT(i->pkt) <= i->n) + (unsigned)(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) @@ -101,7 +101,7 @@ done: } _getdns_rr_iter * -_getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len) +_getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, const size_t pkt_len) { assert(i); @@ -119,7 +119,7 @@ _getdns_rr_iter_init(_getdns_rr_iter *i, const uint8_t *pkt, size_t pkt_len) _getdns_rr_iter * _getdns_single_rr_iter_init( - _getdns_rr_iter *i, const uint8_t *wire, size_t wire_len) + _getdns_rr_iter *i, const uint8_t *wire, const size_t wire_len) { assert(i); diff --git a/src/rr-iter.h b/src/rr-iter.h index d657d484..4eae4df1 100644 --- a/src/rr-iter.h +++ b/src/rr-iter.h @@ -88,16 +88,16 @@ _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 < GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt) ? SECTION_ANSWER - : i->n < GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt) - + GLDNS_NSCOUNT(i->pkt) ? SECTION_AUTHORITY - : i->n < GLDNS_QDCOUNT(i->pkt) - + GLDNS_ANCOUNT(i->pkt) - + GLDNS_NSCOUNT(i->pkt) - + GLDNS_ARCOUNT(i->pkt) ? SECTION_ADDITIONAL + : 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; } diff --git a/src/util-internal.c b/src/util-internal.c index 6934958d..18ca27bf 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) { - int running_sum, n; + unsigned int running_sum, n; _srv_rr *i, *j, swap; /* First move all SRVs with weight 0 to the beginning of the list */ @@ -1379,7 +1379,8 @@ static void _getdns_reply2wire_buf(gldns_buffer *buf, getdns_dict *reply) { getdns_dict *rr_dict, *q_dict, *h_dict; getdns_list *section; - size_t i, pkt_start, ancount, nscount; + size_t i, pkt_start; + uint16_t ancount, nscount; uint32_t qtype, qclass = GETDNS_RRCLASS_IN, rcode = GETDNS_RCODE_NOERROR; getdns_bindata *qname; @@ -1433,7 +1434,8 @@ static void _getdns_reply2wire_buf(gldns_buffer *buf, getdns_dict *reply) static void _getdns_list2wire_buf(gldns_buffer *buf, getdns_list *l) { getdns_dict *rr_dict; - size_t i, pkt_start, ancount; + size_t i, pkt_start; + uint16_t ancount; uint32_t qtype, qclass = GETDNS_RRCLASS_IN; getdns_bindata *qname; From 55cdd8fed3f7523d63829d793d99cf8368cd74c6 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 22:33:10 +0100 Subject: [PATCH 06/14] Fix pedantic warnings in unit tests --- src/test/check_getdns_address.h | 9 ++++++--- src/test/check_getdns_cancel_callback.h | 18 ++++++++++++------ src/test/check_getdns_common.c | 2 +- src/test/check_getdns_common.h | 4 ++++ src/test/check_getdns_context_destroy.h | 12 ++++++++---- src/test/check_getdns_general.h | 21 ++++++++++++++------- src/test/check_getdns_hostname.h | 12 ++++++++---- src/test/check_getdns_service.h | 3 ++- 8 files changed, 55 insertions(+), 26 deletions(-) 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 08331771..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; diff --git a/src/test/check_getdns_common.c b/src/test/check_getdns_common.c index 87f0727e..20310f93 100644 --- a/src/test/check_getdns_common.c +++ b/src/test/check_getdns_common.c @@ -339,7 +339,7 @@ void callbackfn(struct getdns_context *context, getdns_transaction_t transaction_id) { typedef void (*fn_ptr)(struct extracted_response *ex_response); - fn_ptr fn = userarg; + fn_ptr fn = ((fn_cont *)userarg)->fn; (void)context; (void)transaction_id; /* 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 381da9f8..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; 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_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; From eeca7b32b1deaea748364cf78240508fb9fec808 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 22:46:53 +0100 Subject: [PATCH 07/14] One more unused variable --- src/dnssec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dnssec.c b/src/dnssec.c index 961941a4..7d414cd4 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -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 } From 8de9976a2b7d665fc07c6cfbd633e6a2f118ccb4 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 22:56:02 +0100 Subject: [PATCH 08/14] Some more unused variables in stub only mode --- src/context.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/context.c b/src/context.c index dc3b8b92..a3c7aec4 100644 --- a/src/context.c +++ b/src/context.c @@ -1882,11 +1882,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 * @@ -1896,7 +1898,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, @@ -2268,11 +2272,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 * @@ -2282,7 +2288,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); @@ -2550,6 +2558,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) { @@ -2557,6 +2566,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 @@ -2573,7 +2583,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, From 26db6202a5168e32caf5545d3b673b33a75051e0 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 23:15:56 +0100 Subject: [PATCH 09/14] -Werror fixes for clang --- src/context.c | 2 +- src/request-internal.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/context.c b/src/context.c index a3c7aec4..6de1201c 100644 --- a/src/context.c +++ b/src/context.c @@ -3472,7 +3472,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/request-internal.c b/src/request-internal.c index 797fde50..fc8f5e12 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; From 6e9b1b5f53ee53d8bdba74d25c072b9b185195b1 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 23:25:53 +0100 Subject: [PATCH 10/14] One more unused when no TCP_FASTOPEN --- src/stub.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/stub.c b/src/stub.c index 9af045ae..ccca6b95 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) { From 86341fea0836fbfabff89e14b9e05afcda8edec1 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 8 Dec 2016 23:41:49 +0100 Subject: [PATCH 11/14] -Wpedantic -Werror via XTRA_CFLAGS and make --- src/Makefile.in | 2 +- .../tpkg/100-compile.tpkg/100-compile.pre | 12 +------ .../tpkg/100-compile.tpkg/100-compile.test | 2 +- .../200-stub-only-compile.pre | 12 +------ .../200-stub-only-compile.test | 2 +- .../300-event-loops-configure.test | 36 ++++--------------- .../315-event-loops-compile.dsc | 16 +++++++++ .../315-event-loops-compile.post} | 2 +- .../315-event-loops-compile.pre} | 2 +- .../315-event-loops-compile.test} | 4 +-- .../320-event-loops-compile.test | 1 + .../323-event-loops-configure.dsc | 16 --------- .../323-event-loops-configure.pre | 14 -------- .../323-event-loops-configure.test | 16 --------- .../326-event-loops-compile.dsc | 16 --------- 15 files changed, 33 insertions(+), 120 deletions(-) create mode 100644 src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.dsc rename src/test/tpkg/{326-event-loops-compile.tpkg/326-event-loops-compile.post => 315-event-loops-compile.tpkg/315-event-loops-compile.post} (92%) rename src/test/tpkg/{326-event-loops-compile.tpkg/326-event-loops-compile.pre => 315-event-loops-compile.tpkg/315-event-loops-compile.pre} (94%) rename src/test/tpkg/{326-event-loops-compile.tpkg/326-event-loops-compile.test => 315-event-loops-compile.tpkg/315-event-loops-compile.test} (75%) delete mode 100644 src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.dsc delete mode 100644 src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.pre delete mode 100644 src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.test delete mode 100644 src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.dsc diff --git a/src/Makefile.in b/src/Makefile.in index aa5e7fa7..c14afbbb 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -48,7 +48,7 @@ srcdir = @srcdir@ LIBTOOL = ../libtool CC=@CC@ -CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ +CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@ $(XTRA_CFLAGS) LDFLAGS=@LDFLAGS@ @LIBS@ EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@ diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.pre b/src/test/tpkg/100-compile.tpkg/100-compile.pre index f0bd9a5c..6b76edba 100644 --- a/src/test/tpkg/100-compile.tpkg/100-compile.pre +++ b/src/test/tpkg/100-compile.tpkg/100-compile.pre @@ -25,14 +25,4 @@ done rm -fr "${BUILDDIR}/build" mkdir "${BUILDDIR}/build" cd "${BUILDDIR}/build" -if [ -z "$CFLAGS" ] -then - if (echo $*|grep -q CFLAGS) - then - "${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" - else - "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --prefix "${BUILDDIR}/install" - fi -else - "${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" -fi +"${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.test b/src/test/tpkg/100-compile.tpkg/100-compile.test index e527192b..a5539d13 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='-Wpedantic -Werror' diff --git a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre index 1aa7252f..46686828 100644 --- a/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre +++ b/src/test/tpkg/200-stub-only-compile.tpkg/200-stub-only-compile.pre @@ -25,14 +25,4 @@ done rm -fr "${BUILDDIR}/build-stub-only" mkdir "${BUILDDIR}/build-stub-only" cd "${BUILDDIR}/build-stub-only" -if [ -z "$CFLAGS" ] -then - if (echo $*|grep -q CFLAGS) - then - "${SRCROOT}/configure" $* --enable-stub-only - else - "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-stub-only - fi -else - "${SRCROOT}/configure" $* --enable-stub-only -fi +"${SRCROOT}/configure" $* --enable-stub-only 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..421d5483 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='-Wpedantic -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 5242e211..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,32 +7,10 @@ rm -fr "${BUILDDIR}/build-event-loops" mkdir "${BUILDDIR}/build-event-loops" cd "${BUILDDIR}/build-event-loops" -if [ -z "$CFLAGS" ] -then - if (echo $*|grep -q CFLAGS) - then - "${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 - else - "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev --with-libuv \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libev \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libevent --with-libuv \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libev --with-libuv \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libevent \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libev \ - || "${SRCROOT}/configure" CFLAGS="-Wpedantic -Werror" $* --enable-all-drafts --with-getdns_query --with-libuv - fi -else - "${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 -fi +"${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/326-event-loops-compile.tpkg/326-event-loops-compile.post b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post similarity index 92% rename from src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.post rename to src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post index d8029117..4d5f4293 100644 --- a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.post +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.post @@ -1,4 +1,4 @@ -# #-- 326-event-loops-compile.post --# +# #-- 315-event-loops-compile.post --# # source the master var file when it's there if [ -f ../.tpkg.var.master ] then diff --git a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.pre b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre similarity index 94% rename from src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.pre rename to src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre index a4ef762d..4ec46299 100644 --- a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.pre +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.pre @@ -1,4 +1,4 @@ -# #-- 326-event-loops-compile.pre--# +# #-- 315-event-loops-compile.pre--# # source the master var file when it's there if [ -f ../.tpkg.var.master ] then diff --git a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.test b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test similarity index 75% rename from src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.test rename to src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test index 217cfd35..227bb1fc 100644 --- a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.test +++ b/src/test/tpkg/315-event-loops-compile.tpkg/315-event-loops-compile.test @@ -1,8 +1,8 @@ -# #-- 326-event-loops-compile.test --# +# #-- 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 +make XTRA_CFLAGS='-Wpedantic -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/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.dsc b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.dsc deleted file mode 100644 index 3d1dec87..00000000 --- a/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.dsc +++ /dev/null @@ -1,16 +0,0 @@ -BaseName: 323-event-loops-configure -Version: 1.0 -Description: Configure for maximum coverage -CreationDate: do 8 dec 2016 16:21:08 CET -Maintainer: Willem Toorop -Category: -Component: -CmdDepends: -Depends: -Help: -Pre: 323-event-loops-configure.pre -Post: -Test: 323-event-loops-configure.test -AuxFiles: -Passed: -Failure: diff --git a/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.pre b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.pre deleted file mode 100644 index a8423666..00000000 --- a/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.pre +++ /dev/null @@ -1,14 +0,0 @@ -# #-- 323-event-loops-configure.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 diff --git a/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.test b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.test deleted file mode 100644 index b54bd321..00000000 --- a/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.test +++ /dev/null @@ -1,16 +0,0 @@ -# #-- 323-event-loops-configure.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 - -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 diff --git a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.dsc b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.dsc deleted file mode 100644 index c4760a36..00000000 --- a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.dsc +++ /dev/null @@ -1,16 +0,0 @@ -BaseName: 326-event-loops-compile -Version: 1.0 -Description: Compile -CreationDate: do 8 dec 2016 16:21:21 CET -Maintainer: Willem Toorop -Category: -Component: -CmdDepends: -Depends: 300-event-loops-configure.tpkg -Help: -Pre: 326-event-loops-compile.pre -Post: 326-event-loops-compile.post -Test: 326-event-loops-compile.test -AuxFiles: -Passed: -Failure: From 1a26b884ee63f21fa21073843c32432910413538 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 9 Dec 2016 00:16:24 +0100 Subject: [PATCH 12/14] Check for -W* support before use --- configure.ac | 8 +++- src/Makefile.in | 28 +++++++------- src/test/Makefile.in | 37 ++++++++++--------- .../tpkg/100-compile.tpkg/100-compile.test | 2 +- .../200-stub-only-compile.test | 2 +- .../315-event-loops-compile.test | 2 +- 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/configure.ac b/configure.ac index ea2f1ab7..f68aaf36 100644 --- a/configure.ac +++ b/configure.ac @@ -95,10 +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([-Wall],[CFLAGS="$CFLAGS -Wextra"],[],[]) +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 c14afbbb..fb637e3e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -49,6 +49,8 @@ LIBTOOL = ../libtool CC=@CC@ 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) -Wno-error=pedantic -c $(srcdir)/compat/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/compat/$(@:.lo=.c) -o $@ $(UTIL_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -Wno-error=pedantic -Wno-error=unused-parameter -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/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/tpkg/100-compile.tpkg/100-compile.test b/src/test/tpkg/100-compile.tpkg/100-compile.test index a5539d13..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 XTRA_CFLAGS='-Wpedantic -Werror' +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 421d5483..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 XTRA_CFLAGS='-Wpedantic -Werror' +make XTRA_CFLAGS='-Werror' 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 index 227bb1fc..7a420026 100644 --- 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 @@ -5,4 +5,4 @@ [ -f .tpkg.var.test ] && source .tpkg.var.test cd "${BUILDDIR}/build-event-loops" -make XTRA_CFLAGS='-Wpedantic -Werror' +make XTRA_CFLAGS='-Werror' From 3428412629470117da1c0755822cf6b1f292b971 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 9 Dec 2016 12:13:36 +0100 Subject: [PATCH 13/14] Some more minor merge fixes --- src/context.c | 2 +- src/dnssec.c | 2 +- src/general.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/context.c b/src/context.c index 17e4fb2d..7fcca880 100644 --- a/src/context.c +++ b/src/context.c @@ -3404,7 +3404,7 @@ _get_context_settings(getdns_context* context) if (!(list = getdns_list_create_with_context(context))) goto error; - for (i = 0; (int) i < context->namespace_count; ++i) { + for (i = 0; i < context->namespace_count; ++i) { if (getdns_list_set_int(list, i, context->namespaces[i])) { getdns_list_destroy(list); diff --git a/src/dnssec.c b/src/dnssec.c index ec4c9199..2312a286 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -1211,7 +1211,7 @@ static size_t _rr_uncompressed_rdata_size(_getdns_rrtype_iter *rr) static size_t _rr_rdata_size(_getdns_rrtype_iter *rr) { const _getdns_rr_def *rr_def; - int i; + size_t i; rr_def = _getdns_rr_def_lookup(gldns_read_uint16(rr->rr_i.rr_type)); diff --git a/src/general.c b/src/general.c index 3dd7e493..99e4cff5 100644 --- a/src/general.c +++ b/src/general.c @@ -420,7 +420,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop, getdns_network_req *netreq, **netreq_p; getdns_dns_req *req; getdns_dict *localnames_response; - int i; + size_t i; if (!context || !name || (!callbackfn && !internal_cb)) return GETDNS_RETURN_INVALID_PARAMETER; From 4345905a81f683b98d2b356e05032cb2f2ce072b Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Fri, 9 Dec 2016 12:57:47 +0100 Subject: [PATCH 14/14] Address things that came out of VS static analysis Except for the stack usage cases --- src/context.c | 2 +- src/dnssec.c | 8 ++++++++ src/extension/default_eventloop.c | 2 +- src/list.c | 3 +++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/context.c b/src/context.c index 7fcca880..7d542c45 100644 --- a/src/context.c +++ b/src/context.c @@ -419,7 +419,7 @@ sockaddr_dict(getdns_context *context, struct sockaddr *sa) break; port = ntohs(((struct sockaddr_in6 *)sa)->sin6_port); - if (port != GETDNS_PORT_DNS && port != GETDNS_PORT_DNS && + if (port != GETDNS_PORT_ZERO && port != GETDNS_PORT_DNS && getdns_dict_set_int(address, "port", (uint32_t)port)) break; diff --git a/src/dnssec.c b/src/dnssec.c index 2312a286..51d566f2 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -616,6 +616,11 @@ static chain_head *add_rrset2val_chain(struct mem_funcs *mf, head->node_count = node_count; if (!node_count) { + /* When this head has no nodes of itself, it must have found + * another head which has nodes for its labels (i.e. max_head) + */ + assert(max_head != NULL); + head->parent = max_head->parent; return head; } @@ -1090,6 +1095,9 @@ static void val_chain_node_soa_cb(getdns_dns_req *dnsreq) _getdns_rrset *rrset; _getdns_context_clear_outbound_request(dnsreq); + /* A SOA query is always scheduled with a node as the user argument. + */ + assert(node != NULL); for ( i = _getdns_rrset_iter_init(&i_spc, netreq->response , netreq->response_len diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index ce010bc0..c27dacde 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -126,7 +126,7 @@ default_eventloop_clear(getdns_eventloop *loop, getdns_eventloop_event *event) DEBUG_SCHED( "%s(loop: %p, event: %p)\n", __FUNCTION__, loop, event); i = (intptr_t)event->ev - 1; - if (i < 0 || i > FD_SETSIZE) { + if (i < 0 || i >= FD_SETSIZE) { return GETDNS_RETURN_GENERIC_ERROR; } if (event->timeout_cb && !event->read_cb && !event->write_cb) { diff --git a/src/list.c b/src/list.c index 4a73b63f..7a7d3e38 100644 --- a/src/list.c +++ b/src/list.c @@ -353,6 +353,9 @@ _getdns_list_copy(const struct getdns_list * srclist, retval = _getdns_list_append_dict(*dstlist, srclist->items[i].data.dict); break; + default: + retval = GETDNS_RETURN_WRONG_TYPE_REQUESTED; + break; } if (retval != GETDNS_RETURN_GOOD) { getdns_list_destroy(*dstlist);