Blob Blame History Raw
From b7ae41e6ca133e08f1dc62bd49436f51f490f46b Mon Sep 17 00:00:00 2001
From: Lukas Slebodnik <lslebodn@redhat.com>
Date: Tue, 6 Dec 2016 18:07:18 +0100
Subject: [PATCH 1/4] lib replace: Fix detection of features
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If configure script is executed with stricter cflags
"-Werrorr=implicit-function-declaration -Werror=implicit-int"
then detection of few features will fail.

 Checking for C99 vsnprintf : not found
 Checking for HAVE_SHARED_MMAP : not found
 Checking for HAVE_MREMAP : not found

lib/replace/test/shared_mmap.c:18:1:
    error: return type defaults to ‘int’ [-Werror=implicit-int]
 main()
 ^~~~
lib/replace/test/shared_mmap.c: In function ‘main’:
lib/replace/test/shared_mmap.c:25:16:
    error: implicit declaration of function ‘exit’
    [-Werror=implicit-function-declaration]
  if (fd == -1) exit(1);
                ^~~~
lib/replace/test/shared_mmap.c:25:16:
    warning: incompatible implicit declaration of built-in function ‘exit’
lib/replace/test/shared_mmap.c:25:16:
    note: include ‘<stdlib.h>’ or provide a declaration of ‘exit’

Signed-off-by: Lukas Slebodnik <lslebodn@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
---
 lib/replace/test/shared_mmap.c   | 5 ++++-
 lib/replace/test/shared_mremap.c | 5 ++++-
 lib/replace/test/snprintf.c      | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/lib/replace/test/shared_mmap.c b/lib/replace/test/shared_mmap.c
index 50dad8d69648a6993e64d3d0433576319e1ad462..9d6e3fc95aa5d0981df1530582236ba826d1a432 100644
--- a/lib/replace/test/shared_mmap.c
+++ b/lib/replace/test/shared_mmap.c
@@ -4,6 +4,9 @@
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -15,7 +18,7 @@
 #define MAP_FILE 0
 #endif
 
-main()
+int main(void)
 {
 	int *buf;
 	int i; 
diff --git a/lib/replace/test/shared_mremap.c b/lib/replace/test/shared_mremap.c
index 05032ad12e3aa0feb755207ea032216e0665fe0a..08040e2e595f356155f4fb5977b3637b1e76aefb 100644
--- a/lib/replace/test/shared_mremap.c
+++ b/lib/replace/test/shared_mremap.c
@@ -3,6 +3,9 @@
 #if defined(HAVE_UNISTD_H)
 #include <unistd.h>
 #endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
 #include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -18,7 +21,7 @@
 #define MAP_FAILED (int *)-1
 #endif
 
-main()
+int main(void)
 {
 	int *buf;
 	int fd;
diff --git a/lib/replace/test/snprintf.c b/lib/replace/test/snprintf.c
index d06630bcc98d54033fdb5c7e62ecb91eae13e01b..77473f067b26589330d8d1a602d3334332795837 100644
--- a/lib/replace/test/snprintf.c
+++ b/lib/replace/test/snprintf.c
@@ -26,4 +26,4 @@ void foo(const char *format, ...)
 	printf("1");
 	exit(0);
 }
-main() { foo("hello"); }
+int main(void) { foo("hello"); }
-- 
2.11.1