From: Harlan Stenn Date: Sun, 16 Apr 2023 07:12:16 +0000 (-0500) Subject: Disable "embedded NUL in string" messages in libopts, when we can. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=549ca5d2cf4ad93848f3d9e423af1fe33fee78ed;p=thirdparty%2Fntp.git Disable "embedded NUL in string" messages in libopts, when we can. bk: 643b9fd0PJrUtVRe-7c-rj7db45kXg --- diff --git a/ChangeLog b/ChangeLog index d6af39782..5a6d7836e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -75,6 +75,7 @@ Integrated patch from Brian Utterback. * [Bug 2525] Turn on automake subdir-objects across the project. * [Bug 2410] syslog an error message on panic exceeded. +* Disable "embedded NUL in string" messages in libopts, when we can. * Use https in the AC_INIT URLs in configure.ac. * Implement NTP_FUNC_REALPATH. * Lose a gmake construct in ntpd/Makefile.am. diff --git a/sntp/libopts/Makefile.am b/sntp/libopts/Makefile.am index 8248ba76a..0456b02a1 100644 --- a/sntp/libopts/Makefile.am +++ b/sntp/libopts/Makefile.am @@ -8,6 +8,8 @@ endif libopts_la_SOURCES = libopts.c libopts_la_CPPFLAGS = -I$(srcdir) libopts_la_LDFLAGS = -version-info 42:1:17 +# HMS: we're not currently otherwise using AM_CFLAGS>.. +AM_CFLAGS = $(CC_NOFORMAT) EXTRA_DIST = BUILT_SOURCES = MOSTLYCLEANFILES = diff --git a/sntp/m4/ntp_compiler.m4 b/sntp/m4/ntp_compiler.m4 index ae897e72a..ddce106fe 100644 --- a/sntp/m4/ntp_compiler.m4 +++ b/sntp/m4/ntp_compiler.m4 @@ -12,10 +12,12 @@ AC_REQUIRE([AC_PROG_CC_STDC]) dnl AC_REQUIRE([AC_PROG_CC_C89]) dnl AC_REQUIRE([AC_PROG_CC_C99]) +CC_NOFORMAT= CFLAGS_NTP= CPPFLAGS_NTP= LDADD_NTP= LDFLAGS_NTP= +AC_SUBST([CC_NOFORMAT]) AC_SUBST([CFLAGS_NTP]) AC_SUBST([CPPFLAGS_NTP]) AC_SUBST([LDADD_NTP]) @@ -75,7 +77,7 @@ AH_VERBATIM( case "$GCC" in yes) SAVED_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wstrict-overflow" + CFLAGS="$SAVED_CFLAGS -Wstrict-overflow" AC_CACHE_CHECK( [if $CC can handle -Wstrict-overflow], [ntp_cv_gcc_Wstrict_overflow], @@ -101,6 +103,32 @@ case "$GCC" in ) ] ) + # + # libopts specifically builds a string with embedded NULs. + # This causes a bunch of distracting warnings due to -Wformat. + # Let's see if we can figure out how to disable these. + # + CFLAGS="$SAVED_CFLAGS -Wno-format" + AC_CACHE_CHECK( + [if $CC can handle -Wno-format], + [ntp_cv_gcc_Wno_format], + [ + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], [[]])], + [ntp_cv_gcc_Wno_format=yes], + [ntp_cv_gcc_Wno_format=no] + ) + ] + ) + + case "$ntp_cv_gcc_Wno_format" in + yes) + CC_NOFORMAT="$CC_NOFORMAT -Wno-format" + ;; + no) + ;; + esac + CFLAGS="$SAVED_CFLAGS" AS_UNSET([SAVED_CFLAGS]) #