From 3a9a3ad8f9ead7ec963103f8ee0fe905f3982913 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Mon, 7 May 2007 03:02:24 +0000 Subject: r22731: - Fix bug #4594. configure.in determines if -Werror-implicit-function-declaration is available, and if so it enables that flag if --enable-developer is specified. Since the configure tests themselves did not use that flag, it was possible for a configure test to succeed, followed by a failed compilation due to a facility being available but not having a proper declaration in a header file. (This bit me with readahead().) This patch ensures that if implicit function declarations will kill the build, the feature being tested is deselected so the build will succeed. The autoconf manual suggests using return instead of exit in configure tests because the declaration for exit is often missing. We require this now, since we error if prototypes are missing. See section 5.5.1 of http://www.gnu.org/software/autoconf/manual/autoconf.html. This patch makes these changes, because in fact, an external declaration for exit is missing here (and likely elsewhere). I've verified that the features selected (here) with the original configure.in and the new one are the same except for, in my case, readahead. I've also confirmed that the generated Makefile is identical. These changes are not being applied to the 3.0.26 branch because it does not exhibit the initial problem this patch is supposed to solve since it doesn't attempt to use -Werror-implicit-function-declaration. (This used to be commit 4d42720915b8f65842147171f689127e94d1b973) --- source3/tests/crypttest.c | 6 +++--- source3/tests/fcntl_lock.c | 10 +++++----- source3/tests/fcntl_lock64.c | 12 ++++++++---- source3/tests/ftruncate.c | 4 ++-- source3/tests/getgroups.c | 14 +++++++++----- source3/tests/shared_mmap.c | 16 ++++++++-------- source3/tests/summary.c | 1 + source3/tests/trivial.c | 1 + source3/tests/unixsock.c | 21 ++++++++++++--------- 9 files changed, 49 insertions(+), 36 deletions(-) (limited to 'source3/tests') diff --git a/source3/tests/crypttest.c b/source3/tests/crypttest.c index efee2e593d..8bed1c74d1 100644 --- a/source3/tests/crypttest.c +++ b/source3/tests/crypttest.c @@ -814,7 +814,7 @@ main() if((strcmp(c_out1, expected_out) != 0) && (strcmp(c_out2, expected_out) == 0)) - exit(1); + return 1; #ifdef HAVE_BIGCRYPT /* @@ -843,10 +843,10 @@ main() if((strcmp(big_c_out1, big_expected_out) != 0) && (strcmp(big_c_out2, big_expected_out) == 0)) - exit(1); + return 1; } #endif - exit(0); + return 0; } diff --git a/source3/tests/fcntl_lock.c b/source3/tests/fcntl_lock.c index 3dc12a3897..728f94b612 100644 --- a/source3/tests/fcntl_lock.c +++ b/source3/tests/fcntl_lock.c @@ -57,7 +57,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - exit(1); + return 1; } lock.l_type = F_WRLCK; @@ -74,9 +74,9 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { fprintf(stderr,"ERROR: lock test failed (ret=%d errno=%d)\n", ret, (int)errno); - exit(1); + return 1; } else { - exit(0); + return 0; } } @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) if (fd == -1) { fprintf(stderr,"ERROR: failed to open %s (errno=%d)\n", DATA, (int)errno); - exit(1); + return 1; } lock.l_type = F_WRLCK; @@ -117,5 +117,5 @@ int main(int argc, char *argv[]) status); } - exit(status); + return status; } diff --git a/source3/tests/fcntl_lock64.c b/source3/tests/fcntl_lock64.c index e5ecd88fd0..b218fa9282 100644 --- a/source3/tests/fcntl_lock64.c +++ b/source3/tests/fcntl_lock64.c @@ -16,6 +16,10 @@ #include #endif +#ifdef HAVE_SYS_WAIT_H +#include +#endif + #include static int sys_waitpid(pid_t pid,int *status,int options) @@ -40,7 +44,7 @@ int main(int argc, char *argv[]) sleep(2); fd = open64(DATA, O_RDONLY); - if (fd == -1) exit(1); + if (fd == -1) return 1; lock.l_type = F_WRLCK; lock.l_whence = SEEK_SET; @@ -56,10 +60,10 @@ int main(int argc, char *argv[]) if ((ret == -1) || (lock.l_type == F_UNLCK)) { /* printf("No lock conflict\n"); */ - exit(1); + return 1; } else { /* printf("lock conflict\n"); */ - exit(0); + return 0; } } @@ -92,5 +96,5 @@ int main(int argc, char *argv[]) unlink(DATA); - exit(status); + return status; } diff --git a/source3/tests/ftruncate.c b/source3/tests/ftruncate.c index 93282782ee..700d5c8ce5 100644 --- a/source3/tests/ftruncate.c +++ b/source3/tests/ftruncate.c @@ -21,7 +21,7 @@ main() unlink(DATA); if (lseek(fd, 0, SEEK_END) == LEN) { - exit(0); + return 0; } - exit(1); + return 1; } diff --git a/source3/tests/getgroups.c b/source3/tests/getgroups.c index 343fd5a184..c73cd21650 100644 --- a/source3/tests/getgroups.c +++ b/source3/tests/getgroups.c @@ -11,6 +11,10 @@ #include #endif +#if defined(HAVE_STDLIB_H) +#include +#endif + #include #include #include @@ -26,7 +30,7 @@ main() if (sizeof(gid_t) == sizeof(int)) { fprintf(stderr,"gid_t and int are the same size\n"); - exit(1); + return 1; } if (ngroups <= 0) @@ -44,7 +48,7 @@ main() if (ngroups == 0) { printf("WARNING: can't determine getgroups return type\n"); - exit(1); + return 1; } cgroups = (char *)igroups; @@ -52,15 +56,15 @@ main() if (ngroups == 1 && cgroups[2] == 0x42 && cgroups[3] == 0x42) { fprintf(stderr,"getgroups returns gid_t\n"); - exit(1); + return 1; } for (i=0;i 0) exit(0); - exit(1); + if (count > 0) return 0; + return 1; } diff --git a/source3/tests/summary.c b/source3/tests/summary.c index 79a530b013..735f93e116 100644 --- a/source3/tests/summary.c +++ b/source3/tests/summary.c @@ -1,3 +1,4 @@ +#include #include main() diff --git a/source3/tests/trivial.c b/source3/tests/trivial.c index 2723637a0f..ae368a1398 100644 --- a/source3/tests/trivial.c +++ b/source3/tests/trivial.c @@ -1,3 +1,4 @@ +#include main() { exit(0); diff --git a/source3/tests/unixsock.c b/source3/tests/unixsock.c index f2765d68f6..ba384ae362 100644 --- a/source3/tests/unixsock.c +++ b/source3/tests/unixsock.c @@ -1,4 +1,5 @@ -/* -*- c-file-style: "linux" -*- +/* + * -*- c-file-style: "linux" -*- * * Try creating a Unix-domain socket, opening it, and reading from it. * The POSIX name for these is AF_LOCAL/PF_LOCAL. @@ -8,15 +9,17 @@ * on which they are broken under some conditions, such as RedHat 7.0 * (unpatched). We can't build WinBind there at the moment. * - * Coding standard says to always use exit() for this, not return, so - * we do. - * - * Martin Pool , June 2000. */ + * Martin Pool , June 2000. + */ /* TODO: Look for AF_LOCAL (most standard), AF_UNIX, and AF_FILE. */ #include +#if defined(HAVE_UNISTD_H) +#include +#endif + #ifdef HAVE_SYS_SOCKET_H # include #endif @@ -48,7 +51,7 @@ static int bind_socket(char const *filename) /* Create the socket. */ if ((sock_fd = socket(PF_LOCAL, SOCK_STREAM, 0)) < 0) { perror ("socket(PF_LOCAL, SOCK_STREAM)"); - exit(1); + return 1; } /* Bind a name to the socket. */ @@ -67,7 +70,7 @@ static int bind_socket(char const *filename) if (bind(sock_fd, (struct sockaddr *) &name, size) < 0) { perror ("bind"); - exit(1); + return 1; } return sock_fd; @@ -84,10 +87,10 @@ int main(void) alarm(15); /* secs */ if ((sock_fd = bind_socket(filename)) < 0) - exit(1); + return 1; /* the socket will be deleted when autoconf cleans up these files. */ - exit(0); + return 0; } -- cgit