[Asterisk-code-review] configure.ac: Check for unbound version >= 1.5 (asterisk[15])

Joshua Colp asteriskteam at digium.com
Mon Oct 1 07:22:22 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/10266 )

Change subject: configure.ac:  Check for unbound version >= 1.5
......................................................................

configure.ac:  Check for unbound version >= 1.5

In order to do this and provide good feedback, a new macro was
created (AST_EXT_LIB_EXTRA_CHECK) which does the normal check and
path setups for the library then compiles, links and runs a supplied
code fragment to do the final determination.  In this case, the
final code fragment compares UNBOUND_VERSION_MAJOR
and UNBOUND_VERSION_MINOR to determine if they're greater than or
equal to 1.5.

Since we require version 1.5, some code in res_resolver_unbound
was also simplified.

ASTERISK-28045
Reported by: Samuel Galarneau

Change-Id: Iee94ad543cd6f8b118df8c4c7afd9c4e2ca1fa72
---
M autoconf/ast_ext_lib.m4
M configure
M configure.ac
M include/asterisk/autoconfig.h.in
M menuselect/configure
M res/res_resolver_unbound.c
6 files changed, 196 insertions(+), 124 deletions(-)

Approvals:
  Corey Farrell: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/autoconf/ast_ext_lib.m4 b/autoconf/ast_ext_lib.m4
index 8e5b50e..9a91fc3 100644
--- a/autoconf/ast_ext_lib.m4
+++ b/autoconf/ast_ext_lib.m4
@@ -203,3 +203,105 @@
    LIBS="${ast_ext_lib_check_shared_saved_libs}"
 fi
 ])
+
+# Check for existence of a given package ($1), either looking up a function
+# in a library, or, if no function is supplied, only check for the
+# existence of the header files.  Then compile, link and run the supplied
+# code fragment to make the final determination.
+
+# AST_EXT_LIB_EXTRA_CHECK([package], [library], [function], [header],
+#	 [extra libs], [extra cflags], [AC_LANG_PROGRAM(extra check code...)],
+#    ["checking for" display string], ["HAVE_package_" extra variable to set])
+AC_DEFUN([AST_EXT_LIB_EXTRA_CHECK],
+[
+if test "x${PBX_$1}" != "x1" -a "${USE_$1}" != "no"; then
+   pbxlibdir=""
+   # if --with-$1=DIR has been specified, use it.
+   if test "x${$1_DIR}" != "x"; then
+      if test -d ${$1_DIR}/lib; then
+         pbxlibdir="-L${$1_DIR}/lib"
+      else
+         pbxlibdir="-L${$1_DIR}"
+      fi
+   fi
+   m4_ifval([$3], [
+      ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
+      CFLAGS="${CFLAGS} $6"
+      AC_CHECK_LIB([$2], [$3], [AST_$1_FOUND=yes], [AST_$1_FOUND=no], [${pbxlibdir} $5])
+      CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
+   ], [
+      # empty lib, assume only headers
+      AST_$1_FOUND=yes
+   ])
+
+   # now check for the header.
+   if test "${AST_$1_FOUND}" = "yes"; then
+      $1_LIB="${pbxlibdir} -l$2 $5"
+      # if --with-$1=DIR has been specified, use it.
+      if test "x${$1_DIR}" != "x"; then
+         $1_INCLUDE="-I${$1_DIR}/include"
+      fi
+      $1_INCLUDE="${$1_INCLUDE} $6"
+      m4_ifval([$4], [
+         # check for the header
+         ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+         CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+         AC_CHECK_HEADER([$4], [$1_HEADER_FOUND=1], [$1_HEADER_FOUND=0])
+         CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+      ], [
+         # no header, assume found
+         $1_HEADER_FOUND="1"
+      ])
+   fi
+   # Validate the package with the supplied code.
+   if test "x${$1_HEADER_FOUND}" = "x1" ; then
+      AC_MSG_CHECKING(for $8)
+      ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+      CPPFLAGS="${CPPFLAGS} ${$1_INCLUDE}"
+      ast_ext_lib_check_saved_LIBS="${LIBS}"
+      LIBS="${$1_LIB}"
+      AC_LINK_IFELSE(
+         [$7],
+         [
+            if test "x${cross_compiling}" = "xyes" ; then
+               $1_VALIDATED="1"
+               AC_MSG_RESULT([yes (guessed for cross-compile)])
+            else
+               ./conftest$EXEEXT
+               if test $? -eq 0 ; then
+                  $1_VALIDATED="1"
+                  AC_MSG_RESULT(yes)
+               else
+                  AC_MSG_RESULT(no)
+               fi
+            fi
+         ],
+         [
+            AC_MSG_RESULT(no)
+         ]
+      )
+      CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+      LIBS="${ast_ext_lib_check_saved_LIBS}"
+   fi
+
+   if test "x${$1_VALIDATED}" = "x1" ; then
+      m4_ifval([$3], [], [
+         # only checking headers -> no library
+         $1_LIB=""
+      ])
+      PBX_$1=1
+      cat >>confdefs.h <<_ACEOF
+[@%:@define] HAVE_$1 1
+_ACEOF
+      m4_ifval([$9], [
+      cat >>confdefs.h <<_ACEOF
+[@%:@define] HAVE_$1_$9 1
+_ACEOF
+            ])
+   else
+      $1_LIB=""
+      $1_INCLUDE=""
+   fi
+fi
+m4_ifval([$9], [AH_TEMPLATE(m4_bpatsubst([[HAVE_$1_$9]], [(.*)]), [Define if $8])])
+])
diff --git a/configure b/configure
index c45e1b8..fafe27f 100755
--- a/configure
+++ b/configure
@@ -1351,7 +1351,6 @@
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -1542,7 +1541,6 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1795,15 +1793,6 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1941,7 +1930,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -2094,7 +2083,6 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -15335,7 +15323,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -15381,7 +15369,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -15405,7 +15393,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -15450,7 +15438,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -15474,7 +15462,7 @@
     We can't simply define LARGE_OFF_T to be 9223372036854775807,
     since some C++ compilers masquerading as C compilers
     incorrectly reject 9223372036854775807.  */
-#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
+#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
   int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
 		       && LARGE_OFF_T % 2147483647 == 1)
 		      ? 1 : -1];
@@ -16774,8 +16762,6 @@
     if (*(data + i) != *(data3 + i))
       return 14;
   close (fd);
-  free (data);
-  free (data3);
   return 0;
 }
 _ACEOF
@@ -24003,13 +23989,7 @@
 
 
 
-# libunbound v1.5.0 added the ub_ctx_add_ta_autr() API call that we can
-# detect as a useable version so that is going to be the minimum version
-# that we will require.
-# Technically v1.4.21 and later could be used but v1.4.21 has a configure
-# script bug which does not find the ldns library.  The bug is fixed in
-# v1.4.22 but that version is not easily detectable.
-#
+# Check that unbound is installed and the version code fragment compiles
 
 if test "x${PBX_UNBOUND}" != "x1" -a "${USE_UNBOUND}" != "no"; then
    pbxlibdir=""
@@ -24091,63 +24071,77 @@
 
          CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
 
-      if test "x${UNBOUND_HEADER_FOUND}" = "x0" ; then
-         UNBOUND_LIB=""
-         UNBOUND_INCLUDE=""
-      else
-
-         PBX_UNBOUND=1
-         cat >>confdefs.h <<_ACEOF
-#define HAVE_UNBOUND 1
-_ACEOF
-
-      fi
    fi
-fi
-
-
-
-    if test "x${PBX_UNBOUND_CONST_PARAMS}" != "x1" -a "${USE_UNBOUND_CONST_PARAMS}" != "no"; then
-        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for UNBOUND_VERSION_MAJOR declared in unbound.h" >&5
-$as_echo_n "checking for UNBOUND_VERSION_MAJOR declared in unbound.h... " >&6; }
-        saved_cppflags="${CPPFLAGS}"
-        if test "x${UNBOUND_CONST_PARAMS_DIR}" != "x"; then
-            UNBOUND_CONST_PARAMS_INCLUDE="-I${UNBOUND_CONST_PARAMS_DIR}/include"
-        fi
-        CPPFLAGS="${CPPFLAGS} ${UNBOUND_CONST_PARAMS_INCLUDE}"
-
-        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+   # Validate the package with the supplied code.
+   if test "x${UNBOUND_HEADER_FOUND}" = "x1" ; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for unbound version >= 1.5" >&5
+$as_echo_n "checking for unbound version >= 1.5... " >&6; }
+      ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
+      CPPFLAGS="${CPPFLAGS} ${UNBOUND_INCLUDE}"
+      ast_ext_lib_check_saved_LIBS="${LIBS}"
+      LIBS="${UNBOUND_LIB}"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
- #include <unbound.h>
+
+      #include <unbound.h>
 int
 main ()
 {
-#if !defined(UNBOUND_VERSION_MAJOR)
-                                    (void) UNBOUND_VERSION_MAJOR;
-                                #endif
+
+            #if (UNBOUND_VERSION_MAJOR < 1 || (UNBOUND_VERSION_MAJOR == 1 && UNBOUND_VERSION_MINOR < 5 ))
+            #error "Unbound version must be >= 1.5"
+            #endif
+
 
   ;
   return 0;
 }
+
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+if ac_fn_c_try_link "$LINENO"; then :
+
+            if test "x${cross_compiling}" = "xyes" ; then
+               UNBOUND_VALIDATED="1"
+               { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes (guessed for cross-compile)" >&5
+$as_echo "yes (guessed for cross-compile)" >&6; }
+            else
+               ./conftest$EXEEXT
+               if test $? -eq 0 ; then
+                  UNBOUND_VALIDATED="1"
+                  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-                PBX_UNBOUND_CONST_PARAMS=1
-
-$as_echo "#define HAVE_UNBOUND_CONST_PARAMS 1" >>confdefs.h
-
-
+               else
+                  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+               fi
+            fi
 
 else
-     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-        CPPFLAGS="${saved_cppflags}"
-    fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+      CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
+      LIBS="${ast_ext_lib_check_saved_LIBS}"
+   fi
+
+   if test "x${UNBOUND_VALIDATED}" = "x1" ; then
+
+      PBX_UNBOUND=1
+      cat >>confdefs.h <<_ACEOF
+#define HAVE_UNBOUND 1
+_ACEOF
+
+   else
+      UNBOUND_LIB=""
+      UNBOUND_INCLUDE=""
+   fi
+fi
+
 
 
 
diff --git a/configure.ac b/configure.ac
index 69b198a..de31d08 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2295,15 +2295,17 @@
 
 AST_EXT_LIB_CHECK([NEWT], [newt], [newtBell], [newt.h])
 
-# libunbound v1.5.0 added the ub_ctx_add_ta_autr() API call that we can
-# detect as a useable version so that is going to be the minimum version
-# that we will require.
-# Technically v1.4.21 and later could be used but v1.4.21 has a configure
-# script bug which does not find the ldns library.  The bug is fixed in
-# v1.4.22 but that version is not easily detectable.
-#
-AST_EXT_LIB_CHECK([UNBOUND], [unbound], [ub_ctx_delete], [unbound.h])
-AST_C_DECLARE_CHECK([UNBOUND_CONST_PARAMS], [UNBOUND_VERSION_MAJOR], [unbound.h])
+# Check that unbound is installed and the version code fragment compiles
+AST_EXT_LIB_EXTRA_CHECK([UNBOUND], [unbound], [ub_ctx_delete], [unbound.h],
+   [], [], [
+      AC_LANG_PROGRAM( [#include <unbound.h>],
+         [
+            #if (UNBOUND_VERSION_MAJOR < 1 || (UNBOUND_VERSION_MAJOR == 1 && UNBOUND_VERSION_MINOR < 5 ))
+            #error "Unbound version must be >= 1.5"
+            #endif
+         ]
+      )
+   ], [unbound version >= 1.5])
 
 AST_EXT_LIB_CHECK([UNIXODBC], [odbc], [SQLConnect], [sql.h])
 
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index c90f425..c297d9f 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -1183,9 +1183,6 @@
 /* Define to 1 if you have the unbound library. */
 #undef HAVE_UNBOUND
 
-/* Define if your system has UNBOUND_VERSION_MAJOR declared. */
-#undef HAVE_UNBOUND_CONST_PARAMS
-
 /* Define to 1 if you have the <unistd.h> header file. */
 #undef HAVE_UNISTD_H
 
diff --git a/menuselect/configure b/menuselect/configure
index fd7d24b..8efb637 100755
--- a/menuselect/configure
+++ b/menuselect/configure
@@ -692,7 +692,6 @@
 docdir
 oldincludedir
 includedir
-runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -773,7 +772,6 @@
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1026,15 +1024,6 @@
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
-  -runstatedir | --runstatedir | --runstatedi | --runstated \
-  | --runstate | --runstat | --runsta | --runst | --runs \
-  | --run | --ru | --r)
-    ac_prev=runstatedir ;;
-  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
-  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
-  | --run=* | --ru=* | --r=*)
-    runstatedir=$ac_optarg ;;
-
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1172,7 +1161,7 @@
 for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \
 		datadir sysconfdir sharedstatedir localstatedir includedir \
 		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-		libdir localedir mandir runstatedir
+		libdir localedir mandir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1325,7 +1314,6 @@
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
-  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
diff --git a/res/res_resolver_unbound.c b/res/res_resolver_unbound.c
index 89a934c..7f3836a 100644
--- a/res/res_resolver_unbound.c
+++ b/res/res_resolver_unbound.c
@@ -77,17 +77,6 @@
 	</configInfo>
  ***/
 
-/*!
- * Unbound versions <= 1.4.20 declare string function parameters as 'char *'
- * but versions >= 1.4.21 declare them as 'const char *'.  Since CentOS6 is still
- * at 1.4.20, we need to cast away the 'const' if we detect the earlier version.
- */
-#ifdef HAVE_UNBOUND_CONST_PARAMS
-#define UNBOUND_CHAR const char
-#else
-#define UNBOUND_CHAR char
-#endif
-
 /*! \brief Structure for an unbound resolver */
 struct unbound_resolver {
 	/*! \brief Resolver context itself */
@@ -309,7 +298,7 @@
 	data->resolver = ao2_bump(cfg->global->state->resolver);
 	ast_dns_resolver_set_data(query, data);
 
-	res = ub_resolve_async(data->resolver->context, (UNBOUND_CHAR *)ast_dns_query_get_name(query),
+	res = ub_resolve_async(data->resolver->context, ast_dns_query_get_name(query),
 		ast_dns_query_get_rr_type(query), ast_dns_query_get_rr_class(query),
 		ao2_bump(query), unbound_resolver_callback, &data->id);
 
@@ -421,7 +410,7 @@
 	if (!strcmp(cfg->global->hosts, "system")) {
 		res = ub_ctx_hosts(cfg->global->state->resolver->context, NULL);
 	} else if (!ast_strlen_zero(cfg->global->hosts)) {
-		res = ub_ctx_hosts(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->hosts);
+		res = ub_ctx_hosts(cfg->global->state->resolver->context, cfg->global->hosts);
 	}
 
 	if (res) {
@@ -436,7 +425,7 @@
 
 		it_nameservers = ao2_iterator_init(cfg->global->nameservers, 0);
 		while (!res && (nameserver = ao2_iterator_next(&it_nameservers))) {
-			res = ub_ctx_set_fwd(cfg->global->state->resolver->context, (UNBOUND_CHAR *)nameserver);
+			res = ub_ctx_set_fwd(cfg->global->state->resolver->context, nameserver);
 
 			if (res) {
 				ast_log(LOG_ERROR, "Failed to add nameserver '%s' to unbound resolver: %s\n",
@@ -453,7 +442,7 @@
 	if (!strcmp(cfg->global->resolv, "system")) {
 		res = ub_ctx_resolvconf(cfg->global->state->resolver->context, NULL);
 	} else if (!ast_strlen_zero(cfg->global->resolv)) {
-		res = ub_ctx_resolvconf(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->resolv);
+		res = ub_ctx_resolvconf(cfg->global->state->resolver->context, cfg->global->resolv);
 	}
 
 	if (res) {
@@ -463,7 +452,7 @@
 	}
 
 	if (!ast_strlen_zero(cfg->global->ta_file)) {
-		res = ub_ctx_add_ta_file(cfg->global->state->resolver->context, (UNBOUND_CHAR *)cfg->global->ta_file);
+		res = ub_ctx_add_ta_file(cfg->global->state->resolver->context, cfg->global->ta_file);
 
 		if (res) {
 			ast_log(LOG_ERROR, "Failed to set trusted anchor file to '%s' in unbound resolver: %s\n",
@@ -759,13 +748,13 @@
 	static const size_t V4_SIZE = sizeof(struct in_addr);
 	static const size_t V6_SIZE = sizeof(struct in6_addr);
 
-	static UNBOUND_CHAR *DOMAIN1 = "goose.feathers";
-	static UNBOUND_CHAR *DOMAIN2 = "duck.feathers";
+	static const char *DOMAIN1 = "goose.feathers";
+	static const char *DOMAIN2 = "duck.feathers";
 
-	static UNBOUND_CHAR *ADDR1 = "127.0.0.2";
-	static UNBOUND_CHAR *ADDR2 = "127.0.0.3";
-	static UNBOUND_CHAR *ADDR3 = "::1";
-	static UNBOUND_CHAR *ADDR4 = "127.0.0.4";
+	static const char *ADDR1 = "127.0.0.2";
+	static const char *ADDR2 = "127.0.0.3";
+	static const char *ADDR3 = "::1";
+	static const char *ADDR4 = "127.0.0.4";
 
 	char addr1_buf[V4_SIZE];
 	char addr2_buf[V4_SIZE];
@@ -805,7 +794,7 @@
 	ub_ctx_zone_add(resolver->context, DOMAIN2, "static");
 
 	for (i = 0; i < ARRAY_LEN(records); ++i) {
-		ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
+		ub_ctx_data_add(resolver->context, records[i].as_string);
 	}
 
 	for (i = 0; i < ARRAY_LEN(runs); ++i) {
@@ -827,7 +816,7 @@
 
 cleanup:
 	for (i = 0; i < ARRAY_LEN(records); ++i) {
-		ub_ctx_data_remove(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
+		ub_ctx_data_remove(resolver->context, records[i].as_string);
 	}
 	ub_ctx_zone_remove(resolver->context, DOMAIN1);
 	ub_ctx_zone_remove(resolver->context, DOMAIN2);
@@ -1031,10 +1020,10 @@
 
 	static const size_t V4_SIZE = sizeof(struct in_addr);
 
-	static UNBOUND_CHAR *DOMAIN1 = "goose.feathers";
-	static UNBOUND_CHAR *DOMAIN2 = "duck.feathers";
+	static const char *DOMAIN1 = "goose.feathers";
+	static const char *DOMAIN2 = "duck.feathers";
 
-	static UNBOUND_CHAR *ADDR1 = "127.0.0.2";
+	static const char *ADDR1 = "127.0.0.2";
 
 	char addr1_buf[V4_SIZE];
 
@@ -1065,7 +1054,7 @@
 	ub_ctx_zone_add(resolver->context, DOMAIN2, "static");
 
 	for (i = 0; i < ARRAY_LEN(records); ++i) {
-		ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].as_string);
+		ub_ctx_data_add(resolver->context, records[i].as_string);
 	}
 
 	for (i = 0; i < ARRAY_LEN(runs); ++i) {
@@ -1253,7 +1242,7 @@
 	ub_ctx_zone_add(resolver->context, DOMAIN1, "static");
 
 	for (i = 0; i < ARRAY_LEN(records); ++i) {
-		ub_ctx_data_add(resolver->context, (UNBOUND_CHAR *)records[i].zone_entry);
+		ub_ctx_data_add(resolver->context, records[i].zone_entry);
 	}
 
 	if (ast_dns_resolve(DOMAIN1, ns_t_naptr, ns_c_in, &result)) {
@@ -1330,8 +1319,8 @@
 	RAII_VAR(struct unbound_config *, cfg, NULL, ao2_cleanup);
 	RAII_VAR(struct ast_dns_result *, result, NULL, ast_dns_result_free);
 	const struct ast_dns_record *record;
-	static UNBOUND_CHAR *DOMAIN1 = "taco.bananas";
-	static UNBOUND_CHAR *DOMAIN1_SRV = "taco.bananas 12345 IN SRV 10 20 5060 sip.taco.bananas";
+	static const char *DOMAIN1 = "taco.bananas";
+	static const char *DOMAIN1_SRV = "taco.bananas 12345 IN SRV 10 20 5060 sip.taco.bananas";
 	enum ast_test_result_state res = AST_TEST_PASS;
 
 	switch (cmd) {

-- 
To view, visit https://gerrit.asterisk.org/10266
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: Iee94ad543cd6f8b118df8c4c7afd9c4e2ca1fa72
Gerrit-Change-Number: 10266
Gerrit-PatchSet: 2
Gerrit-Owner: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2 (1000185)
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181001/3a32ba07/attachment-0001.html>


More information about the asterisk-code-review mailing list