These changes avoid a few additional cases of implicit function declarations and implicit ints. --- aclocal.m4 | 82 ++++++++++++++++++++++++++++++--------------------- configure | 73 ++++++++++++++++++++++++++++----------------- m4/intdiv0.m4 | 3 ++ 3 files changed, 98 insertions(+), 60 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4 index c42dbf3b..a384739d 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -139,7 +139,7 @@ typedef int (*_bashfunc)(const char *, ...); typedef int (*_bashfunc)(); #endif #include <stdlib.h> -main() +int main() { _bashfunc pf; pf = (_bashfunc) printf; @@ -200,7 +200,7 @@ AC_CACHE_VAL(bash_cv_under_sys_siglist, #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif -main() +int main() { char *msg = (char *)_sys_siglist[2]; exit(msg == 0); @@ -228,7 +228,7 @@ AC_CACHE_VAL(bash_cv_sys_siglist, #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif -main() +int main() { char *msg = sys_siglist[2]; exit(msg == 0); @@ -281,7 +281,10 @@ AC_CACHE_VAL(bash_cv_dup2_broken, #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> -main() +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { int fd1, fd2, fl; fd1 = open("/dev/null", 2); @@ -308,7 +311,8 @@ AC_DEFUN(BASH_FUNC_STRSIGNAL, [AC_MSG_CHECKING([for the existence of strsignal]) AC_CACHE_VAL(bash_cv_have_strsignal, [AC_TRY_LINK([#include <sys/types.h> -#include <signal.h>], +#include <signal.h> +#include <string.h>], [char *s = (char *)strsignal(2);], bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)]) AC_MSG_RESULT($bash_cv_have_strsignal) @@ -329,6 +333,9 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, #ifdef HAVE_UNISTD_H # include <unistd.h> #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif /* HAVE_SYS_STAT_H */ #if defined(HAVE_DIRENT_H) # include <dirent.h> #else @@ -344,7 +351,7 @@ AC_CACHE_VAL(bash_cv_opendir_not_robust, # endif #endif /* HAVE_DIRENT_H */ #include <stdlib.h> -main() +int main() { DIR *dir; int fd, err; @@ -524,7 +531,7 @@ AC_TRY_RUN([ #include <sys/time.h> #include <sys/resource.h> #include <stdlib.h> -main() +int main() { #ifdef HAVE_QUAD_T struct rlimit rl; @@ -609,7 +616,7 @@ getenv (name) { return "42"; } -main() +int main() { char *s; /* The next allows this program to run, but does not allow bash to link @@ -695,10 +702,13 @@ AC_DEFUN(BASH_FUNC_ULIMIT_MAXFDS, [AC_MSG_CHECKING(whether ulimit can substitute for getdtablesize) AC_CACHE_VAL(bash_cv_ulimit_maxfds, [AC_TRY_RUN([ -main() +#ifdef HAVE_ULIMIT_H +#include <ulimit.h> +#endif +int main() { long maxfds = ulimit(4, 0L); -exit (maxfds == -1L); +return maxfds == -1L; } ], bash_cv_ulimit_maxfds=yes, bash_cv_ulimit_maxfds=no, [AC_MSG_WARN(cannot check ulimit if cross compiling -- defaulting to no) @@ -719,11 +729,11 @@ AC_CACHE_VAL(bash_cv_getcwd_malloc, #include <unistd.h> #endif -main() +int main() { char *xpwd; xpwd = getcwd(0, 0); - exit (xpwd == 0); + return xpwd == 0; } ], bash_cv_getcwd_malloc=yes, bash_cv_getcwd_malloc=no, [AC_MSG_WARN(cannot check whether getcwd allocates memory when cross-compiling -- defaulting to no) @@ -768,12 +778,12 @@ AC_CACHE_VAL(bash_cv_fnm_extmatch, [AC_TRY_RUN([ #include <fnmatch.h> -main() +int main() { #ifdef FNM_EXTMATCH - exit (0); + return 0; #else - exit (1); + return 1; #endif } ], bash_cv_fnm_extmatch=yes, bash_cv_fnm_extmatch=no, @@ -799,7 +809,7 @@ AC_CACHE_VAL(bash_cv_func_sigsetjmp, #include <setjmp.h> #include <stdlib.h> -main() +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) exit (1); @@ -844,11 +854,13 @@ AC_MSG_CHECKING(whether or not strcoll and strcmp differ) AC_CACHE_VAL(bash_cv_func_strcoll_broken, [AC_TRY_RUN([ #include <stdio.h> +#include <stdlib.h> +#include <string.h> #if defined (HAVE_LOCALE_H) #include <locale.h> #endif -main(c, v) +int main(c, v) int c; char *v[]; { @@ -947,7 +959,7 @@ AC_CACHE_VAL(bash_cv_struct_stat_st_blocks, #include <sys/stat.h> ], [ -main() +int main() { static struct stat a; if (a.st_blocks) return 0; @@ -1254,8 +1266,11 @@ AC_CACHE_VAL(bash_cv_pgrp_pipe, #ifdef HAVE_UNISTD_H # include <unistd.h> #endif +#ifdef HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif #include <stdlib.h> -main() +int main() { # ifdef GETPGRP_VOID # define getpgID() getpgrp() @@ -1350,13 +1365,13 @@ int s; nsigint++; } -main() +int main() { nsigint = 0; set_signal_handler(SIGINT, sigint); kill((int)getpid(), SIGINT); kill((int)getpid(), SIGINT); - exit(nsigint != 2); + return nsigint != 2; } ], bash_cv_must_reinstall_sighandlers=no, bash_cv_must_reinstall_sighandlers=yes, [AC_MSG_WARN(cannot check signal handling if cross compiling -- defaulting to no) @@ -1433,10 +1448,11 @@ AC_CACHE_VAL(bash_cv_sys_named_pipes, #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include <stdio.h> #include <stdlib.h> /* Add more tests in here as appropriate. */ -main() +int main() { int fd, err; @@ -1673,7 +1689,7 @@ AC_CACHE_VAL(bash_cv_unusable_rtsigs, # define NSIG 64 #endif -main () +int main () { int n_sigs = 2 * NSIG; #ifdef SIGRTMIN @@ -1787,7 +1803,7 @@ bash_cv_wcwidth_broken, #include <locale.h> #include <wchar.h> -main(c, v) +int main(c, v) int c; char **v; { @@ -1855,7 +1871,7 @@ AC_CACHE_VAL(ac_cv_rl_version, extern int rl_gnu_readline_p; -main() +int main() { FILE *fp; fp = fopen("conftest.rlv", "w"); @@ -1945,7 +1961,7 @@ AC_CACHE_VAL(bash_cv_func_ctype_nonascii, #include <stdio.h> #include <ctype.h> -main(c, v) +int main(c, v) int c; char *v[]; { @@ -1966,7 +1982,7 @@ char *v[]; r1 = isprint(x); x -= 128; r2 = isprint(x); - exit (r1 == 0 || r2 == 0); + return r1 == 0 || r2 == 0; } ], bash_cv_func_ctype_nonascii=yes, bash_cv_func_ctype_nonascii=no, [AC_MSG_WARN(cannot check ctype macros if cross compiling -- defaulting to no) @@ -1991,15 +2007,15 @@ AC_CACHE_VAL(bash_cv_wcontinued_broken, #ifndef errno extern int errno; #endif -main() +int main() { int x; x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED); if (x == -1 && errno == EINVAL) - exit (1); + return 1; else - exit (0); + return 0; } ], bash_cv_wcontinued_broken=no,bash_cv_wcontinued_broken=yes, [AC_MSG_WARN(cannot check WCONTINUED if cross compiling -- defaulting to no) @@ -2058,7 +2074,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF], #include <stdio.h> #include <stdlib.h> -main() +int main() { int n; n = snprintf (0, 0, "%s", "0123456"); @@ -2114,7 +2130,7 @@ foo(format, va_alist) return n; } -main() +int main() { int n; n = foo("%s", "0123456"); @@ -2143,7 +2159,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset, #include <sys/wait.h> -main(c, v) +int main(c, v) int c; char **v; { diff --git a/configure b/configure index 088118ba..a578d5b1 100755 --- a/configure +++ b/configure @@ -5396,7 +5396,7 @@ else extern int rl_gnu_readline_p; -main() +int main() { FILE *fp; fp = fopen("conftest.rlv", "w"); @@ -7881,6 +7881,9 @@ else #include <stdlib.h> #include <signal.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif static void sigfpe_handler (int sig) @@ -15415,7 +15418,7 @@ else #include <locale.h> #include <wchar.h> -main(c, v) +int main(c, v) int c; char **v; { @@ -16858,7 +16861,7 @@ else #include <stdio.h> #include <ctype.h> -main(c, v) +int main(c, v) int c; char *v[]; { @@ -16879,7 +16882,7 @@ char *v[]; r1 = isprint(x); x -= 128; r2 = isprint(x); - exit (r1 == 0 || r2 == 0); + return r1 == 0 || r2 == 0; } _ACEOF @@ -16917,7 +16920,10 @@ else #include <sys/types.h> #include <fcntl.h> #include <stdlib.h> -main() +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +int main() { int fd1, fd2, fl; fd1 = open("/dev/null", 2); @@ -16968,8 +16974,11 @@ else #ifdef HAVE_UNISTD_H # include <unistd.h> #endif +#ifdef HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif #include <stdlib.h> -main() +int main() { # ifdef GETPGRP_VOID # define getpgID() getpgrp() @@ -17186,7 +17195,7 @@ else #if !HAVE_DECL_SYS_SIGLIST extern char *sys_siglist[]; #endif -main() +int main() { char *msg = sys_siglist[2]; exit(msg == 0); @@ -17268,7 +17277,7 @@ else #ifndef UNDER_SYS_SIGLIST_DECLARED extern char *_sys_siglist[]; #endif -main() +int main() { char *msg = (char *)_sys_siglist[2]; exit(msg == 0); @@ -17673,7 +17682,7 @@ else #include <sys/time.h> #include <sys/resource.h> #include <stdlib.h> -main() +int main() { #ifdef HAVE_QUAD_T struct rlimit rl; @@ -18200,7 +18209,7 @@ else #include <sys/wait.h> -main(c, v) +int main(c, v) int c; char **v; { @@ -18528,6 +18537,7 @@ else /* end confdefs.h. */ #include <sys/types.h> #include <signal.h> +#include <string.h> int main () { @@ -18572,6 +18582,9 @@ else #ifdef HAVE_UNISTD_H # include <unistd.h> #endif /* HAVE_UNISTD_H */ +#ifdef HAVE_SYS_STAT_H +# include <sys/stat.h> +#endif /* HAVE_SYS_STAT_H */ #if defined(HAVE_DIRENT_H) # include <dirent.h> #else @@ -18587,7 +18600,7 @@ else # endif #endif /* HAVE_DIRENT_H */ #include <stdlib.h> -main() +int main() { DIR *dir; int fd, err; @@ -18638,10 +18651,13 @@ else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -main() +#ifdef HAVE_ULIMIT_H +#include <ulimit.h> +#endif +int main() { long maxfds = ulimit(4, 0L); -exit (maxfds == -1L); +return maxfds == -1L; } _ACEOF @@ -18716,7 +18732,7 @@ getenv (name) { return "42"; } -main() +int main() { char *s; /* The next allows this program to run, but does not allow bash to link @@ -18768,11 +18784,11 @@ else #include <unistd.h> #endif -main() +int main() { char *xpwd; xpwd = getcwd(0, 0); - exit (xpwd == 0); + return xpwd == 0; } _ACEOF @@ -18824,7 +18840,7 @@ else #include <setjmp.h> #include <stdlib.h> -main() +int main() { #if !defined (_POSIX_VERSION) || !defined (HAVE_POSIX_SIGNALS) exit (1); @@ -18889,11 +18905,13 @@ else /* end confdefs.h. */ #include <stdio.h> +#include <stdlib.h> +#include <string.h> #if defined (HAVE_LOCALE_H) #include <locale.h> #endif -main(c, v) +int main(c, v) int c; char *v[]; { @@ -18964,7 +18982,7 @@ else #include <stdio.h> #include <stdlib.h> -main() +int main() { int n; n = snprintf (0, 0, "%s", "0123456"); @@ -19043,7 +19061,7 @@ foo(format, va_alist) return n; } -main() +int main() { int n; n = foo("%s", "0123456"); @@ -19346,13 +19364,13 @@ int s; nsigint++; } -main() +int main() { nsigint = 0; set_signal_handler(SIGINT, sigint); kill((int)getpid(), SIGINT); kill((int)getpid(), SIGINT); - exit(nsigint != 2); + return nsigint != 2; } _ACEOF @@ -19467,10 +19485,11 @@ else #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#include <stdio.h> #include <stdlib.h> /* Add more tests in here as appropriate. */ -main() +int main() { int fd, err; @@ -19668,15 +19687,15 @@ else #ifndef errno extern int errno; #endif -main() +int main() { int x; x = waitpid(-1, (int *)0, WNOHANG|WCONTINUED); if (x == -1 && errno == EINVAL) - exit (1); + return 1; else - exit (0); + return 0; } _ACEOF @@ -19784,7 +19803,7 @@ else # define NSIG 64 #endif -main () +int main () { int n_sigs = 2 * NSIG; #ifdef SIGRTMIN diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4 index e63fcf10..92f3ae5c 100644 --- a/m4/intdiv0.m4 +++ b/m4/intdiv0.m4 @@ -33,6 +33,9 @@ changequote([,])dnl [AC_LANG_SOURCE([[ #include <stdlib.h> #include <signal.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif static void sigfpe_handler (int sig) -- 2.21.0