From 2c736abb4c5b2caa0f3760c68ec9d50bca0dfb93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20R=C3=BChsen?= Date: Tue, 7 Jun 2016 09:56:01 +0200 Subject: [PATCH] Fix warning about redefinition of MAP_FAILED * src/sysdep.h: Removed definition of MAP_FAILED * src/utils.c: Check and define MAP_FAILED after including sys/mmap.h --- src/sysdep.h | 10 ---------- src/utils.c | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/sysdep.h b/src/sysdep.h index 29516af3..8da76119 100644 --- a/src/sysdep.h +++ b/src/sysdep.h @@ -143,16 +143,6 @@ int snprintf (char *str, size_t count, const char *fmt, ...); int vsnprintf (char *str, size_t count, const char *fmt, va_list arg); #endif -/* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't - provide MAP_FAILED, a symbolic constant for the value returned by - mmap() when it doesn't work. Usually, this constant should be -1. - This only makes sense for files that use mmap() and include - sys/mman.h *before* sysdep.h, but doesn't hurt others. */ - -#ifndef MAP_FAILED -# define MAP_FAILED ((void *) -1) -#endif - /* Enable system fnmatch only on systems where fnmatch.h is usable. If the fnmatch on your system is buggy, undef this symbol and a replacement implementation will be used instead. */ diff --git a/src/utils.c b/src/utils.c index 8285e134..b07da9f4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -37,9 +37,6 @@ as that of the covered work. */ #include #include #include -#ifdef HAVE_MMAP -# include -#endif #ifdef HAVE_PROCESS_H # include /* getpid() */ #endif @@ -90,6 +87,18 @@ as that of the covered work. */ # define USE_SIGNAL_TIMEOUT #endif +/* Some systems (Linux libc5, "NCR MP-RAS 3.0", and others) don't + provide MAP_FAILED, a symbolic constant for the value returned by + mmap() when it doesn't work. Usually, this constant should be -1. + This only makes sense for files that use mmap() and include + sys/mman.h *before* sysdep.h, but doesn't hurt others. */ +#ifdef HAVE_MMAP +# include +# ifndef MAP_FAILED +# define MAP_FAILED ((void *) -1) +# endif +#endif + #include "utils.h" #include "hash.h"