2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-28 12:57:50 +00:00

Fix test for unsetenv() returning void with clang 16.

Clang has dropped support for K&R function definitions so rewrite
the test to require a unsetenv() prototype in stdlib.h.
Fixes GitHub issue #302.
This commit is contained in:
Todd C. Miller 2023-08-28 18:37:06 -06:00
parent 07003d9020
commit 1eb4392e14
2 changed files with 12 additions and 25 deletions

17
configure vendored
View File

@ -23317,39 +23317,29 @@ printf %s "checking whether unsetenv returns void... " >&6; }
if test ${sudo_cv_func_unsetenv_void+y} if test ${sudo_cv_func_unsetenv_void+y}
then : then :
printf %s "(cached) " >&6 printf %s "(cached) " >&6
else case e in #(
e) if test "$cross_compiling" = yes
then :
sudo_cv_func_unsetenv_void=no
else case e in #( else case e in #(
e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
$ac_includes_default $ac_includes_default
int unsetenv();
int int
main (void) main (void)
{ {
return unsetenv("FOO") != 0; return unsetenv("FOO");
; ;
return 0; return 0;
} }
_ACEOF _ACEOF
if ac_fn_c_try_run "$LINENO" if ac_fn_c_try_compile "$LINENO"
then : then :
sudo_cv_func_unsetenv_void=no sudo_cv_func_unsetenv_void=no
else case e in #( else case e in #(
e) sudo_cv_func_unsetenv_void=yes ;; e) sudo_cv_func_unsetenv_void=yes ;;
esac esac
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
conftest.$ac_objext conftest.beam conftest.$ac_ext ;;
esac
fi
;;
esac esac
fi fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_func_unsetenv_void" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $sudo_cv_func_unsetenv_void" >&5
@ -23373,6 +23363,7 @@ else case e in #(
/* end confdefs.h. */ /* end confdefs.h. */
$ac_includes_default $ac_includes_default
int putenv(const char *string) {return 0;} int putenv(const char *string) {return 0;}
int int
main (void) main (void)
{ {

View File

@ -342,16 +342,12 @@ dnl check unsetenv() return value
dnl dnl
AC_DEFUN([SUDO_FUNC_UNSETENV_VOID], AC_DEFUN([SUDO_FUNC_UNSETENV_VOID],
[AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void], [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void],
[AC_RUN_IFELSE([AC_LANG_PROGRAM( [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [
[AC_INCLUDES_DEFAULT [return unsetenv("FOO");]
int unsetenv();
], [
[return unsetenv("FOO") != 0;]
]) ])
], ],
[sudo_cv_func_unsetenv_void=no], [sudo_cv_func_unsetenv_void=no],
[sudo_cv_func_unsetenv_void=yes], [sudo_cv_func_unsetenv_void=yes])])
[sudo_cv_func_unsetenv_void=no])])
if test $sudo_cv_func_unsetenv_void = yes; then if test $sudo_cv_func_unsetenv_void = yes; then
AC_DEFINE(UNSETENV_VOID, 1, AC_DEFINE(UNSETENV_VOID, 1,
[Define to 1 if the 'unsetenv' function returns void instead of 'int'.]) [Define to 1 if the 'unsetenv' function returns void instead of 'int'.])
@ -362,10 +358,10 @@ dnl
dnl check putenv() argument for const dnl check putenv() argument for const
dnl dnl
AC_DEFUN([SUDO_FUNC_PUTENV_CONST], AC_DEFUN([SUDO_FUNC_PUTENV_CONST],
[AC_CACHE_CHECK([whether putenv takes a const argument], [AC_CACHE_CHECK([whether putenv takes a const argument], [sudo_cv_func_putenv_const],
sudo_cv_func_putenv_const,
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
int putenv(const char *string) {return 0;}], [])], int putenv(const char *string) {return 0;}
], [])],
[sudo_cv_func_putenv_const=yes], [sudo_cv_func_putenv_const=yes],
[sudo_cv_func_putenv_const=no]) [sudo_cv_func_putenv_const=no])
]) ])