From: Timo Sirainen Date: Tue, 15 Dec 2009 19:01:20 +0000 (-0500) Subject: Compile fix for systems where unsetenv() returns void. X-Git-Tag: 2.0.beta2~128 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=56c15678d4fd710155caecb09be82f9355bd19d7;p=thirdparty%2Fdovecot%2Fcore.git Compile fix for systems where unsetenv() returns void. FreeBSD 6.4, for example. --HG-- branch : HEAD --- diff --git a/configure.in b/configure.in index 3ff4555351..1b67a13d99 100644 --- a/configure.in +++ b/configure.in @@ -1301,6 +1301,21 @@ AC_CHECK_LIB(sendfile, sendfile, [ fi ]) +AC_CACHE_CHECK([if unsetenv returns int],i_cv_unsetenv_ret_int,[ + AC_TRY_COMPILE([ + #include + ], [ + if (unsetenv("env") < 0) ; + ], [ + i_cv_unsetenv_ret_int=yes + ], [ + i_cv_unsetenv_ret_int=no + ]) +]) +if test $i_cv_unsetenv_ret_int = yes; then + AC_DEFINE(UNSETENV_RET_INT,, Define if unsetenv() returns int) +fi + dnl * Check for crypt() if unistd.h compiles with _XOPEN_SOURCE + _XPG6 dnl * Add other macros there too "just in case". AC_CACHE_CHECK([if we should use _XPG6 macro for crypt()],i_cv_use_xpg6_crypt,[ diff --git a/src/lib/env-util.c b/src/lib/env-util.c index 643b0866e0..cde68c0838 100644 --- a/src/lib/env-util.c +++ b/src/lib/env-util.c @@ -25,8 +25,12 @@ void env_put(const char *env) void env_remove(const char *name) { #ifdef HAVE_UNSETENV +#ifdef UNSETENV_RET_INT if (unsetenv(name) < 0) i_fatal("unsetenv(%s) failed: %m", name); +#else + unsetenv(name); +#endif #else extern char **environ; unsigned int len;