From e71816dc640462aab0870fc46cf1d56b63575f45 Mon Sep 17 00:00:00 2001 From: Cheyenne Wills Date: Fri, 28 Jan 2022 14:10:46 -0700 Subject: [PATCH 5/5] Linux-5.17: Kernel build uses -Wcast-function-type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The linux 5.17 commit: "Makefile: Enable -Wcast-function-type" (552a23a0) added the -Wcast-function-type compiler flag for kernel module builds. This change catches a type mismatch in the external files obtained from heimdal: hcrypto/evp.c and hcrypto/evp-algs.c and produces the following type of compile time error messages. src/libafs/MODLOAD-.../evp.c: In function ‘hc_EVP_md_null’: src/libafs/MODLOAD-.../evp.c:501:2: error: cast between incompatible function types from ‘void (*)(void *)’ to ‘int (*)(EVP_MD_CTX *)’ {aka ‘int (*)(struct hc_EVP_MD_CTX *)’} [-Werror=cast-function-type] 501 | (hc_evp_md_init)null_Init, | ^ Use AX_APPEND_COMPILE_FLAGS to create a CFLAGS_NOCAST_FUNCTION_TYPE macro to disable this warning and update the CFLAGS for these 2 files for the Linux libafs build. Update the CODING documentation to add the new exceptions. In addition add a brief description on how to set up autoconf to add a new build macro to suppress compiler warnings. Note: upstream heimdal has committed a fix for this in: hcrypto: Fix return type for null_Init, null_Update and null_Final (fc4b3ce49b) Change-Id: I05b716867016a33ca02a791ed6bc5a7d846de608 Reviewed-on: https://gerrit.openafs.org/14881 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot Reviewed-by: Andrew Deason (cherry picked from commit 6bdfa976731ce07f3236893ecf12abb9e169b882) --- CODING | 12 +++++++++++- src/cf/osconf.m4 | 4 ++++ src/libafs/MakefileProto.LINUX.in | 5 +++-- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/CODING b/CODING index 5d62dbb0b..c26697934 100644 --- a/CODING +++ b/CODING @@ -265,7 +265,13 @@ the fix is to mark that warning as ignored, but only for clang. For example: # endif #endif -If a pragma isn't available for your particular warning, you will need to +If the source cannot be changed to add a pragma, you might be abe to use the +autoconf function AX_APPEND_COMPILE_FLAGS to create a new macro that disables +the warning and then use macro for the build options for that file. For an +example, see how the autoconf macro CFLAGS_NOIMPLICIT_FALLTHROUGH is defined and +used. + +Finally if there isn't a way to disable the specific warning, you will need to disable all warnings for the file in question. You can do this by supplying the autoconf macro @CFLAGS_NOERROR@ in the build options for the file. For example: @@ -288,6 +294,10 @@ bucoord/commands.c : all : Ubik_Call : signed vs unsigned for dates butc/tcudbprocs.c : all : ubik_Call external/heimdal/hcrypto/validate.c: all: statement with empty body +external/heimdal/hcrypto/evp.c: cast-function-type + : Linux kernel build uses -Wcast-function-type +external/heimdal/hcrypto/evp-algs.c: cast-function-type + : Linux kernel build uses -Wcast-function-type kauth/admin_tools.c : strict-proto : ubik_Call kauth/authclient.c : strict-proto : ubik_Call nonsense libadmin/kas/afs_kasAdmin.c: strict-proto : ubik_Call nonsense diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4 index 1e1b08057..11f3eeae5 100644 --- a/src/cf/osconf.m4 +++ b/src/cf/osconf.m4 @@ -665,6 +665,7 @@ CFLAGS_NOERROR= CFLAGS_NOSTRICT=-fno-strict-aliasing CFLAGS_NOUNUSED= CFLAGS_NOOLDSTYLE= +CFLAGS_NOCAST_FUNCTION_TYPE= XCFLAGS_NOCHECKING="$XCFLAGS" if test "x$GCC" = "xyes"; then @@ -677,6 +678,8 @@ if test "x$GCC" = "xyes"; then CFLAGS_NOERROR="-Wno-error" CFLAGS_NOUNUSED="-Wno-unused" CFLAGS_NOOLDSTYLE="-Wno-old-style-definition" + AX_APPEND_COMPILE_FLAGS([-Wno-cast-function-type], + [CFLAGS_NOCAST_FUNCTION_TYPE]) AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode]) else CFLAGS_NOSTRICT= @@ -753,6 +756,7 @@ AC_SUBST(CFLAGS_NOERROR) AC_SUBST(CFLAGS_NOSTRICT) AC_SUBST(CFLAGS_NOUNUSED) AC_SUBST(CFLAGS_NOOLDSTYLE) +AC_SUBST(CFLAGS_NOCAST_FUNCTION_TYPE) AC_SUBST(XCFLAGS64) AC_SUBST(XLDFLAGS) AC_SUBST(XLDFLAGS64) diff --git a/src/libafs/MakefileProto.LINUX.in b/src/libafs/MakefileProto.LINUX.in index d98fa05ad..8e98afd56 100644 --- a/src/libafs/MakefileProto.LINUX.in +++ b/src/libafs/MakefileProto.LINUX.in @@ -79,8 +79,9 @@ CFLAGS_rxkad_common.o = -I${TOP_SRCDIR}/rxkad -I$(TOP_OBJDIR)/src/rxkad CFLAGS_opr_rbtree.o = -I${TOP_SRCDIR}/opr CFLAGS_evp.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \ - -DHAVE_CONFIG_H -CFLAGS_evp-algs.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto + -DHAVE_CONFIG_H @CFLAGS_NOCAST_FUNCTION_TYPE@ +CFLAGS_evp-algs.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \ + @CFLAGS_NOCAST_FUNCTION_TYPE@ CFLAGS_evp-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto CFLAGS_rand-timer-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto CFLAGS_rand-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto -- 2.35.1