bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* relocatable-prog: fix gcc warning on mingw
@ 2019-04-26 23:27 Bruno Haible
  0 siblings, 0 replies; only message in thread
From: Bruno Haible @ 2019-04-26 23:27 UTC (permalink / raw)
  To: bug-gnulib

On mingw, I'm seeing this warning:

progreloc.c:156:1: warning: ‘maybe_executable’ defined but not used [-Wunused-function]
 maybe_executable (const char *filename)
 ^~~~~~~~~~~~~~~~

This patch should fix it.


2019-04-26  Bruno Haible  <bruno@clisp.org>

	relocatable-prog: Fix gcc warning on mingw.
	* lib/progreloc.c (maybe_executable): Don't define on native Windows and
	on EMX.

diff --git a/lib/progreloc.c b/lib/progreloc.c
index b3eb503..9d81efa 100644
--- a/lib/progreloc.c
+++ b/lib/progreloc.c
@@ -151,17 +151,20 @@ full_read (int fd, void *buf, size_t count)
 static int executable_fd = -1;
 #endif
 
+/* Define this function only when it's needed.  */
+#if !(defined WINDOWS_NATIVE || defined __EMX__)
+
 /* Tests whether a given pathname may belong to the executable.  */
 static bool
 maybe_executable (const char *filename)
 {
   /* The native Windows API lacks the access() function.  */
-#if !defined WINDOWS_NATIVE
+# if !defined WINDOWS_NATIVE
   if (access (filename, X_OK) < 0)
     return false;
-#endif
+# endif
 
-#if defined __linux__ || defined __CYGWIN__
+# if defined __linux__ || defined __CYGWIN__
   if (executable_fd >= 0)
     {
       /* If we already have an executable_fd, check that filename points to
@@ -179,11 +182,13 @@ maybe_executable (const char *filename)
             return false;
         }
     }
-#endif
+# endif
 
   return true;
 }
 
+#endif
+
 /* Determine the full pathname of the current executable, freshly allocated.
    Return NULL if unknown.
    Guaranteed to work on Linux and native Windows.  Likely to work on the



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-26 23:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-26 23:27 relocatable-prog: fix gcc warning on mingw Bruno Haible

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).