From: Otto Moerbeek Date: Wed, 25 Sep 2019 08:00:47 +0000 (+0200) Subject: Add lgtm annotations and #error directives if we're configured wrongly. X-Git-Tag: dnsdist-1.4.0-rc3~2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=290995c1d26a0e4ef49e143f08eaaf86070c473c;p=pdns Add lgtm annotations and #error directives if we're configured wrongly. Already showing its worth: a few ac checks were missing. --- diff --git a/configure.ac b/configure.ac index 1546caf43..78a5d88ee 100644 --- a/configure.ac +++ b/configure.ac @@ -130,7 +130,9 @@ PDNS_CHECK_VIRTUALENV PDNS_FROM_GIT dnl Checks for library functions. -AC_CHECK_FUNCS_ONCE([strcasestr localtime_r recvmmsg sched_setscheduler getrandom arc4random]) +dnl the *_r functions are in posix so we can use them unconditionally, but the ext/yahttp code is +dnl using the defines. +AC_CHECK_FUNCS_ONCE([strcasestr localtime_r gmtime_r recvmmsg sched_setscheduler getrandom arc4random]) AM_CONDITIONAL([HAVE_RECVMMSG], [test "x$ac_cv_func_recvmmsg" = "xyes"]) diff --git a/ext/yahttp/yahttp/utility.hpp b/ext/yahttp/yahttp/utility.hpp index 8a93ae6d4..3e8920a1c 100644 --- a/ext/yahttp/yahttp/utility.hpp +++ b/ext/yahttp/yahttp/utility.hpp @@ -70,7 +70,8 @@ namespace YaHTTP { fromTm(&tm); #else struct tm *tm; - tm = localtime(&t); + #error define HAVE_LOCALTIME_R + tm = localtime(&t); // lgtm [cpp/potentially-dangerous-function] fromTm(tm); #endif #ifndef HAVE_TM_GMTOFF @@ -79,7 +80,8 @@ namespace YaHTTP { gmtime_r(&t, &tm); t2 = mktime(&tm); # else - tm = gmtime(&t); + #error define HAVE_LOCALTIME_R + tm = gmtime(&t); // lgtm [cpp/potentially-dangerous-function] t2 = mktime(tm); # endif this->utc_offset = ((t2-t)/10)*10; // removes any possible differences. @@ -93,7 +95,8 @@ namespace YaHTTP { fromTm(&tm); #else struct tm *tm; - tm = gmtime(&t); + #error define HAVE_GMTIME_R + tm = gmtime(&t);// lgtm [cpp/potentially-dangerous-function] fromTm(tm); #endif #ifndef HAVE_TM_GMTOFF diff --git a/pdns/dnsdistdist/configure.ac b/pdns/dnsdistdist/configure.ac index 544a9bb1b..88eabe39d 100644 --- a/pdns/dnsdistdist/configure.ac +++ b/pdns/dnsdistdist/configure.ac @@ -48,6 +48,9 @@ AX_AVAILABLE_SYSTEMD AX_CHECK_SYSTEMD_FEATURES AM_CONDITIONAL([HAVE_SYSTEMD], [ test x"$systemd" = "xy" ]) +dnl the *_r functions are in posix so we can use them unconditionally, but the ext/yahttp code is +dnl using the defines. +AC_CHECK_FUNCS_ONCE([localtime_r gmtime_r]) AC_SUBST([YAHTTP_CFLAGS], ['-I$(top_srcdir)/ext/yahttp']) AC_SUBST([YAHTTP_LIBS], ['$(top_builddir)/ext/yahttp/yahttp/libyahttp.la']) AC_SUBST([IPCRYPT_CFLAGS], ['-I$(top_srcdir)/ext/ipcrypt']) diff --git a/pdns/recursordist/configure.ac b/pdns/recursordist/configure.ac index a2c14cc5b..6d05754ba 100644 --- a/pdns/recursordist/configure.ac +++ b/pdns/recursordist/configure.ac @@ -93,7 +93,9 @@ PDNS_WITH_NET_SNMP PDNS_CHECK_RAGEL([pdns/dnslabeltext.cc], [www.powerdns.com]) PDNS_CHECK_CURL -AC_CHECK_FUNCS_ONCE([strcasestr getrandom arc4random]) +dnl the *_r functions are in posix so we can use them unconditionally, but the ext/yahttp code is +dnl using the defines. +AC_CHECK_FUNCS_ONCE([localtime_r gmtime_r strcasestr getrandom arc4random]) PDNS_CHECK_PTHREAD_NP