lib replace: Fix detection of features
authorLukas Slebodnik <lslebodn@redhat.com>
Tue, 6 Dec 2016 17:07:18 +0000 (18:07 +0100)
committerRalph Boehme <slow@samba.org>
Mon, 2 Jan 2017 13:12:27 +0000 (14:12 +0100)
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
lib/replace/test/shared_mremap.c
lib/replace/test/snprintf.c

index 50dad8d69648a6993e64d3d0433576319e1ad462..9d6e3fc95aa5d0981df1530582236ba826d1a432 100644 (file)
@@ -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; 
index 05032ad12e3aa0feb755207ea032216e0665fe0a..08040e2e595f356155f4fb5977b3637b1e76aefb 100644 (file)
@@ -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;
index d06630bcc98d54033fdb5c7e62ecb91eae13e01b..77473f067b26589330d8d1a602d3334332795837 100644 (file)
@@ -26,4 +26,4 @@ void foo(const char *format, ...)
        printf("1");
        exit(0);
 }
-main() { foo("hello"); }
+int main(void) { foo("hello"); }