bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: bug-gnulib@gnu.org
Subject: secure_getenv: Fix warning on Android
Date: Tue, 10 Jan 2023 14:27:36 +0100	[thread overview]
Message-ID: <3743212.hUukIMtRk4@nimes> (raw)

Building a testdir on Android, I see this warning:

../../gllib/secure_getenv.c:34:7: warning: call to undeclared function 'issetugid'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

The reason is that the function issetugid is not declared; therefore we should
not use it.

This patch fixes it.

2023-01-10  Bruno Haible  <bruno@clisp.org>

	secure_getenv: Fix warning on Android.
	* m4/secure_getenv.m4 (gl_FUNC_SECURE_GETENV): Test for issetugid using
	* lib/secure_getenv.c: Fix comment regarding issetugid.

diff --git a/lib/secure_getenv.c b/lib/secure_getenv.c
index 8b2dd5ec17..a0bc0cf817 100644
--- a/lib/secure_getenv.c
+++ b/lib/secure_getenv.c
@@ -30,7 +30,7 @@ secure_getenv (char const *name)
 #if HAVE___SECURE_GETENV /* glibc */
   return __secure_getenv (name);
-#elif HAVE_ISSETUGID /* OS X, FreeBSD, NetBSD, OpenBSD */
+#elif HAVE_ISSETUGID /* musl, OS X, FreeBSD, NetBSD, OpenBSD, Solaris, Minix */
   if (issetugid ())
     return NULL;
   return getenv (name);
diff --git a/m4/secure_getenv.m4 b/m4/secure_getenv.m4
index 85104e3488..acb06507cc 100644
--- a/m4/secure_getenv.m4
+++ b/m4/secure_getenv.m4
@@ -1,4 +1,4 @@
-# Look up an environment variable more securely.
+# secure_getenv.m4 serial 2
 dnl Copyright 2013-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -20,7 +20,7 @@ AC_DEFUN([gl_FUNC_SECURE_GETENV],
   if test $ac_cv_func___secure_getenv = no; then
-    AC_CHECK_FUNCS([issetugid])
+    gl_CHECK_FUNCS_ANDROID([issetugid], [[#include <unistd.h>]])
   AC_CHECK_FUNCS_ONCE([getuid geteuid getgid getegid])

                 reply	other threads:[~2023-01-10 14:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3743212.hUukIMtRk4@nimes \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).