diff --git a/configure.ac b/configure.ac index bf442574..8fcfd158 100644 --- a/configure.ac +++ b/configure.ac @@ -99,6 +99,7 @@ CFLAGS="$CFLAGS" 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"],[],[]) case "$host_os" in linux* ) CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE" diff --git a/src/Makefile.in b/src/Makefile.in index 763e22da..f533e3d8 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -101,10 +101,10 @@ $(GLDNS_OBJ): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/gldns/$(@:.lo=.c) -o $@ $(COMPAT_OBJ): - $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -c $(srcdir)/compat/$(@:.lo=.c) -o $@ + $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -Wno-error=pedantic -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) -Wno-error=pedantic -Wno-error=unused-parameter -c $(srcdir)/util/$(@:.lo=.c) -o $@ $(JSMN_OBJ): $(LIBTOOL) --quiet --tag=CC --mode=compile $(CC) $(CFLAGS) -DJSMN_GETDNS -c $(srcdir)/jsmn/$(@:.lo=.c) -o $@ diff --git a/src/extension/default_eventloop.c b/src/extension/default_eventloop.c index b05d8ec3..e83d9b89 100644 --- a/src/extension/default_eventloop.c +++ b/src/extension/default_eventloop.c @@ -83,7 +83,7 @@ default_eventloop_schedule(getdns_eventloop *loop, #endif default_loop->fd_events[fd] = event; default_loop->fd_timeout_times[fd] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) fd + 1; + event->ev = (void *) (intptr_t) (fd + 1); DEBUG_SCHED( "scheduled read/write at %d\n", fd); return GETDNS_RETURN_GOOD; @@ -104,7 +104,7 @@ default_eventloop_schedule(getdns_eventloop *loop, if (default_loop->timeout_events[i] == NULL) { default_loop->timeout_events[i] = event; default_loop->timeout_times[i] = get_now_plus(timeout); - event->ev = (void *) (intptr_t) i + 1; + event->ev = (void *) (intptr_t) (i + 1); DEBUG_SCHED( "scheduled timeout at %d\n", (int)i); return GETDNS_RETURN_GOOD; @@ -159,6 +159,9 @@ default_eventloop_cleanup(getdns_eventloop *loop) static void default_read_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->read_cb(event->userarg); } @@ -166,6 +169,9 @@ default_read_cb(int fd, getdns_eventloop_event *event) static void default_write_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->write_cb(event->userarg); } @@ -173,6 +179,9 @@ default_write_cb(int fd, getdns_eventloop_event *event) static void default_timeout_cb(int fd, getdns_eventloop_event *event) { +#if !defined(SCHED_DEBUG) || !SCHED_DEBUG + (void)fd; +#endif DEBUG_SCHED( "%s(fd: %d, event: %p)\n", __FUNCTION__, fd, event); event->timeout_cb(event->userarg); } diff --git a/src/test/tpkg/100-compile.tpkg/100-compile.pre b/src/test/tpkg/100-compile.tpkg/100-compile.pre index 6b76edba..f0bd9a5c 100644 --- a/src/test/tpkg/100-compile.tpkg/100-compile.pre +++ b/src/test/tpkg/100-compile.tpkg/100-compile.pre @@ -25,4 +25,14 @@ done rm -fr "${BUILDDIR}/build" mkdir "${BUILDDIR}/build" cd "${BUILDDIR}/build" -"${SRCROOT}/configure" $* --prefix "${BUILDDIR}/install" +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 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 46686828..1aa7252f 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,4 +25,14 @@ done rm -fr "${BUILDDIR}/build-stub-only" mkdir "${BUILDDIR}/build-stub-only" cd "${BUILDDIR}/build-stub-only" -"${SRCROOT}/configure" $* --enable-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 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..5242e211 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,32 @@ 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 +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 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 new file mode 100644 index 00000000..3d1dec87 --- /dev/null +++ b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.dsc @@ -0,0 +1,16 @@ +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 new file mode 100644 index 00000000..a8423666 --- /dev/null +++ b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.pre @@ -0,0 +1,14 @@ +# #-- 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 new file mode 100644 index 00000000..b54bd321 --- /dev/null +++ b/src/test/tpkg/323-event-loops-configure.tpkg/323-event-loops-configure.test @@ -0,0 +1,16 @@ +# #-- 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 new file mode 100644 index 00000000..c4760a36 --- /dev/null +++ b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.dsc @@ -0,0 +1,16 @@ +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: diff --git a/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.post b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.post new file mode 100644 index 00000000..d8029117 --- /dev/null +++ b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.post @@ -0,0 +1,20 @@ +# #-- 326-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/326-event-loops-compile.tpkg/326-event-loops-compile.pre b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.pre new file mode 100644 index 00000000..a4ef762d --- /dev/null +++ b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.pre @@ -0,0 +1,24 @@ +# #-- 326-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/326-event-loops-compile.tpkg/326-event-loops-compile.test b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.test new file mode 100644 index 00000000..217cfd35 --- /dev/null +++ b/src/test/tpkg/326-event-loops-compile.tpkg/326-event-loops-compile.test @@ -0,0 +1,8 @@ +# #-- 326-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 diff --git a/src/tools/getdns_query.c b/src/tools/getdns_query.c index ecd16c65..71d4f015 100644 --- a/src/tools/getdns_query.c +++ b/src/tools/getdns_query.c @@ -1372,6 +1372,8 @@ static void request_cb( if (qname_str != unknown_qname) free(qname_str); +#else + (void)transaction_id; #endif assert(msg); diff --git a/src/types-internal.h b/src/types-internal.h index 356f2353..06eea0da 100644 --- a/src/types-internal.h +++ b/src/types-internal.h @@ -287,29 +287,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 @@ -319,7 +319,7 @@ typedef struct getdns_dns_req { * validating is touched by _getdns_get_validation_chain only and * freed is touched by _getdns_submit_netreq only */ - int validating : 1; + unsigned validating : 1; int *freed; uint16_t tls_query_padding_blocksize; diff --git a/src/ub_loop.c b/src/ub_loop.c index c0040289..1fc9daa7 100644 --- a/src/ub_loop.c +++ b/src/ub_loop.c @@ -115,9 +115,9 @@ typedef struct my_event { } my_event; #define AS_UB_LOOP(x) \ - (((union {struct ub_event_base* a; _getdns_ub_loop* b;})x).b) + ((_getdns_ub_loop *)(x)) #define AS_MY_EVENT(x) \ - (((union {struct ub_event* a; my_event* b;})x).b) + ((my_event *)(x)) static void my_event_base_free(struct ub_event_base* base) {