lwp: Ignore dangling-pointer warning in process.c

In lwp/process.c the address of a stack variable is saved as part of
creating a new context.  GCC-12 is flagging the statement with a
diagnostic:

  ./process.c:46:24: error: storing the address of local variable
      ‘stackvar’ in ‘*savearea.topstack’ [-Werror=dangling-pointer=]
   46 |     savearea->topstack = (char *)&stackvar;
      |     ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~

In this particular case, the code is meaning to save the address of the
stack in preparation of setting up a new context, which requires knowing
the address the current stack.

The diagnostic is changed from a warning to an error when configured
with --enable-checking.

Set the env variable CFLAGS_NODANGLING_POINTER to
'-Wno-dangling-pointer' if the compiler supports the option and update
the src/lwp/Makefile.in to use the flag when compiling process.c

Change-Id: Ibec956b505c0edad9b74d63b9bb7805f6f0cba01
Reviewed-on: https://gerrit.openafs.org/14957
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Cheyenne Wills 2022-06-07 11:14:55 -06:00 committed by Benjamin Kaduk
parent 1d1a20c332
commit 748ae0fc25
3 changed files with 8 additions and 1 deletions

4
CODING
View File

@ -351,4 +351,6 @@ rxkad/ticket5.c : format-truncation : inside included file v5der.c in the
function _heim_time2generalizedtime, the
two snprintf calls raise
format-truncation warnings due to the
arithmetic on tm_year and tm_mon fields
arithmetic on tm_year and tm_mon fields
lwp/process.c : dangling-pointer : Ignore the legitimate use of saving
the address of a stack variable

View File

@ -631,6 +631,7 @@ CFLAGS_NOUNUSED=
CFLAGS_NOOLDSTYLE=
CFLAGS_NOIMPLICIT_FALLTHROUGH=
CFLAGS_NOCAST_FUNCTION_TYPE=
CFLAGS_NODANGLING_POINTER=
XCFLAGS_NOCHECKING="$XCFLAGS"
if test "x$GCC" = "xyes"; then
@ -648,6 +649,8 @@ if test "x$GCC" = "xyes"; then
[CFLAGS_NOIMPLICIT_FALLTHROUGH], [-Werror])
AX_APPEND_COMPILE_FLAGS([-Wno-cast-function-type],
[CFLAGS_NOCAST_FUNCTION_TYPE], [-Werror])
AX_APPEND_COMPILE_FLAGS([-Wno-dangling-pointer],
[CFLAGS_NODANGLING_POINTER], [-Werror])
AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode])
else
CFLAGS_NOSTRICT=
@ -732,6 +735,7 @@ AC_SUBST(CFLAGS_NOUNUSED)
AC_SUBST(CFLAGS_NOOLDSTYLE)
AC_SUBST(CFLAGS_NOIMPLICIT_FALLTHROUGH)
AC_SUBST(CFLAGS_NOCAST_FUNCTION_TYPE)
AC_SUBST(CFLAGS_NODANGLING_POINTER)
AC_SUBST(CFLAGS_WERROR)
AC_SUBST(XCFLAGS64)
AC_SUBST(XLDFLAGS)

View File

@ -60,6 +60,7 @@ process.default.s:
# Making process.o for $(SYS_NAME)
# The files "process.s" and "process.S" may be used internally,
# but will be removed after building the .o
CFLAGS_process.o = @CFLAGS_NODANGLING_POINTER@
process.o : process.default.s process.i386.s process.amd64.s process.c lwp.o
@set -x; case "$(SYS_NAME)" in \
sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53 | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5* | arm_linux* ) \