cf: Resolve implicit function definition for memset 31/14631/4
authorCheyenne Wills <cwills@sinenomine.net>
Fri, 4 Jun 2021 16:18:39 +0000 (10:18 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Thu, 10 Jun 2021 16:29:09 +0000 (12:29 -0400)
The autoconf function OPENAFS_HAVE_STRUCT_FIELD can produce a compiler
warning for an implicit function definition for memset, however with
macOS 11 (Big Sur) the default compiler flags have been changed
(-Werror=implicit-function-declaration) so that this is now flagged as an
error. As an error this can lead to an incorrect result returned by
OPENAFS_HAVE_STRUCT_FIELD.

Add an include for <string.h> to provide the necessary definition for
memset.

Note, both gcc and clang can produce the implicit function definition
warning.

Change-Id: I05ea43e1712c0450b7d1a78d4e953bfad9be28b9
Reviewed-on: https://gerrit.openafs.org/14631
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/cf/have-struct-field.m4

index 36f75c9..98a976b 100644 (file)
@@ -4,7 +4,9 @@ dnl should be shipping AC_ macros.
 AC_DEFUN([OPENAFS_HAVE_STRUCT_FIELD], [
 define(cache_val, translit(ac_cv_type_$1_$2, [A-Z ], [a-z_]))
 AC_CACHE_CHECK([for $2 in $1], cache_val,[
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$3]],
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+        $3
+        #include <string.h>]],
         [[$1 x; memset(&x, 0, sizeof(x)); x.$2]])],
         [cache_val=yes],
         [cache_val=no])