Linux-5.17: Kernel build uses -Wcast-function-type

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 <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
This commit is contained in:
Cheyenne Wills 2022-01-28 14:10:46 -07:00 committed by Benjamin Kaduk
parent 738a6487ad
commit 6bdfa97673
3 changed files with 18 additions and 3 deletions

12
CODING
View File

@ -306,7 +306,13 @@ the fix is to mark that warning as ignored, but only for clang. For example:
# endif # endif
#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 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 the autoconf macro @CFLAGS_NOERROR@ in the build options for the file. For
example: example:
@ -332,6 +338,10 @@ bucoord/commands.c : all : Ubik_Call
: signed vs unsigned for dates : signed vs unsigned for dates
butc/tcudbprocs.c : all : ubik_Call butc/tcudbprocs.c : all : ubik_Call
external/heimdal/hcrypto/validate.c: all: statement with empty body 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/admin_tools.c : strict-proto : ubik_Call
kauth/authclient.c : strict-proto : ubik_Call nonsense kauth/authclient.c : strict-proto : ubik_Call nonsense
libadmin/kas/afs_kasAdmin.c: strict-proto : ubik_Call nonsense libadmin/kas/afs_kasAdmin.c: strict-proto : ubik_Call nonsense

View File

@ -630,6 +630,7 @@ CFLAGS_NOSTRICT=-fno-strict-aliasing
CFLAGS_NOUNUSED= CFLAGS_NOUNUSED=
CFLAGS_NOOLDSTYLE= CFLAGS_NOOLDSTYLE=
CFLAGS_NOIMPLICIT_FALLTHROUGH= CFLAGS_NOIMPLICIT_FALLTHROUGH=
CFLAGS_NOCAST_FUNCTION_TYPE=
XCFLAGS_NOCHECKING="$XCFLAGS" XCFLAGS_NOCHECKING="$XCFLAGS"
if test "x$GCC" = "xyes"; then if test "x$GCC" = "xyes"; then
@ -645,6 +646,8 @@ if test "x$GCC" = "xyes"; then
CFLAGS_NOOLDSTYLE="-Wno-old-style-definition" CFLAGS_NOOLDSTYLE="-Wno-old-style-definition"
AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough], AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough],
[CFLAGS_NOIMPLICIT_FALLTHROUGH]) [CFLAGS_NOIMPLICIT_FALLTHROUGH])
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]) AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode])
else else
CFLAGS_NOSTRICT= CFLAGS_NOSTRICT=
@ -728,6 +731,7 @@ AC_SUBST(CFLAGS_NOSTRICT)
AC_SUBST(CFLAGS_NOUNUSED) AC_SUBST(CFLAGS_NOUNUSED)
AC_SUBST(CFLAGS_NOOLDSTYLE) AC_SUBST(CFLAGS_NOOLDSTYLE)
AC_SUBST(CFLAGS_NOIMPLICIT_FALLTHROUGH) AC_SUBST(CFLAGS_NOIMPLICIT_FALLTHROUGH)
AC_SUBST(CFLAGS_NOCAST_FUNCTION_TYPE)
AC_SUBST(CFLAGS_WERROR) AC_SUBST(CFLAGS_WERROR)
AC_SUBST(XCFLAGS64) AC_SUBST(XCFLAGS64)
AC_SUBST(XLDFLAGS) AC_SUBST(XLDFLAGS)

View File

@ -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_opr_rbtree.o = -I${TOP_SRCDIR}/opr
CFLAGS_evp.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \ CFLAGS_evp.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \
-DHAVE_CONFIG_H -DHAVE_CONFIG_H @CFLAGS_NOCAST_FUNCTION_TYPE@
CFLAGS_evp-algs.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto 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_evp-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
CFLAGS_rand-timer-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 CFLAGS_rand-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto