|
| 1 | +From ee4983302d6f052e77ab0332d2a128d169c2eacb Mon Sep 17 00:00:00 2001 |
| 2 | +From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= < [email protected]> |
| 3 | +Date: Tue, 15 Nov 2022 21:45:27 +0100 |
| 4 | +Subject: [PATCH] Remove default-int/k&r declarations from the configure macros |
| 5 | + |
| 6 | +Recently, Clang tried to switch to having K&R prototypes and other |
| 7 | +non-strictly-conforming prototypes error out, as a result of C2x changes |
| 8 | +to the standard. These have been located across many packages, and |
| 9 | +range in severity from mild compile errors to runtime misconfiguration |
| 10 | +as a result of broken configure scripts. |
| 11 | + |
| 12 | +This covers all the instances I could find by grepping around the |
| 13 | +codebase, and gets OpenLDAP building on my system. |
| 14 | + |
| 15 | +Bug: https://bugs.gentoo.org/871288 |
| 16 | +Bug: https://bugs.gentoo.org/871372 |
| 17 | +--- a/build/openldap.m4 |
| 18 | ++++ b/build/openldap.m4 |
| 19 | +@@ -154,6 +154,7 @@ fi |
| 20 | + if test $ol_cv_header_stdc = yes; then |
| 21 | + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. |
| 22 | + AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <ctype.h> |
| 23 | ++#include <stdlib.h> |
| 24 | + #ifndef HAVE_EBCDIC |
| 25 | + # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') |
| 26 | + # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) |
| 27 | +@@ -394,9 +395,7 @@ AC_DEFUN([OL_PTHREAD_TEST_FUNCTION],[[ |
| 28 | + AC_DEFUN([OL_PTHREAD_TEST_PROGRAM], |
| 29 | + [AC_LANG_SOURCE([OL_PTHREAD_TEST_INCLUDES |
| 30 | + |
| 31 | +-int main(argc, argv) |
| 32 | +- int argc; |
| 33 | +- char **argv; |
| 34 | ++int main(int argc, char **argv) |
| 35 | + { |
| 36 | + OL_PTHREAD_TEST_FUNCTION |
| 37 | + } |
| 38 | +@@ -518,7 +517,7 @@ AC_CACHE_CHECK([for compatible POSIX regex],ol_cv_c_posix_regex,[ |
| 39 | + #include <sys/types.h> |
| 40 | + #include <regex.h> |
| 41 | + static char *pattern, *string; |
| 42 | +-main() |
| 43 | ++int main(void) |
| 44 | + { |
| 45 | + int rc; |
| 46 | + regex_t re; |
| 47 | +@@ -545,7 +544,8 @@ AC_DEFUN([OL_C_UPPER_LOWER], |
| 48 | + [AC_CACHE_CHECK([if toupper() requires islower()],ol_cv_c_upper_lower,[ |
| 49 | + AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 50 | + #include <ctype.h> |
| 51 | +-main() |
| 52 | ++#include <stdlib.h> |
| 53 | ++int main(void) |
| 54 | + { |
| 55 | + if ('C' == toupper('C')) |
| 56 | + exit(0); |
| 57 | +@@ -603,7 +603,7 @@ AC_DEFUN([OL_NONPOSIX_STRERROR_R], |
| 58 | + ]])],[ol_cv_nonposix_strerror_r=yes],[ol_cv_nonposix_strerror_r=no]) |
| 59 | + else |
| 60 | + AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 61 | +- main() { |
| 62 | ++ int main(void) { |
| 63 | + char buf[100]; |
| 64 | + buf[0] = 0; |
| 65 | + strerror_r( 1, buf, sizeof buf ); |
| 66 | +--- a/configure.ac |
| 67 | ++++ b/configure.ac |
| 68 | +@@ -1031,7 +1031,11 @@ dnl ---------------------------------------------------------------- |
| 69 | + AC_CHECK_HEADERS( sys/epoll.h ) |
| 70 | + if test "${ac_cv_header_sys_epoll_h}" = yes; then |
| 71 | + AC_MSG_CHECKING(for epoll system call) |
| 72 | +- AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(int argc, char **argv) |
| 73 | ++ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h> |
| 74 | ++#ifdef HAVE_SYS_POLL_H |
| 75 | ++#include <sys/epoll.h> |
| 76 | ++#endif |
| 77 | ++int main(int argc, char **argv) |
| 78 | + { |
| 79 | + int epfd = epoll_create(256); |
| 80 | + exit (epfd == -1 ? 1 : 0); |
| 81 | +@@ -1493,10 +1497,8 @@ pthread_rwlock_t rwlock; |
| 82 | + dnl save the flags |
| 83 | + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ |
| 84 | + #include <pthread.h> |
| 85 | +-#ifndef NULL |
| 86 | +-#define NULL (void*)0 |
| 87 | +-#endif |
| 88 | +-]], [[pthread_detach(NULL);]])],[ol_cv_func_pthread_detach=yes],[ol_cv_func_pthread_detach=no]) |
| 89 | ++pthread_t thread; |
| 90 | ++]], [[pthread_detach(thread);]])],[ol_cv_func_pthread_detach=yes],[ol_cv_func_pthread_detach=no]) |
| 91 | + ]) |
| 92 | + |
| 93 | + if test $ol_cv_func_pthread_detach = no ; then |
| 94 | +@@ -1551,6 +1553,9 @@ dnl esac |
| 95 | + AC_CACHE_CHECK([if select yields when using pthreads], |
| 96 | + ol_cv_pthread_select_yields,[ |
| 97 | + AC_RUN_IFELSE([AC_LANG_SOURCE([[ |
| 98 | ++#define _XOPEN_SOURCE 500 /* For pthread_setconcurrency() on glibc */ |
| 99 | ++#include <stdlib.h> |
| 100 | ++#include <stdio.h> |
| 101 | + #include <sys/types.h> |
| 102 | + #include <sys/time.h> |
| 103 | + #include <unistd.h> |
| 104 | +@@ -1561,8 +1566,7 @@ dnl esac |
| 105 | + |
| 106 | + static int fildes[2]; |
| 107 | + |
| 108 | +-static void *task(p) |
| 109 | +- void *p; |
| 110 | ++static void *task(void *p) |
| 111 | + { |
| 112 | + int i; |
| 113 | + struct timeval tv; |
| 114 | +@@ -1586,9 +1590,7 @@ static void *task(p) |
| 115 | + exit(0); /* if we exit here, the select blocked the whole process */ |
| 116 | + } |
| 117 | + |
| 118 | +-int main(argc, argv) |
| 119 | +- int argc; |
| 120 | +- char **argv; |
| 121 | ++int main(int argc, char **argv) |
| 122 | + { |
| 123 | + pthread_t t; |
| 124 | + |
| 125 | +--- a/contrib/ldaptcl/tclAppInit.c |
| 126 | ++++ b/contrib/ldaptcl/tclAppInit.c |
| 127 | +@@ -45,9 +45,7 @@ EXTERN int Tcltest_Init _ANSI_ARGS_((Tcl_Interp *interp)); |
| 128 | + */ |
| 129 | + |
| 130 | + int |
| 131 | +-main(argc, argv) |
| 132 | +- int argc; /* Number of command-line arguments. */ |
| 133 | +- char **argv; /* Values of command-line arguments. */ |
| 134 | ++main(int argc, char **argv) |
| 135 | + { |
| 136 | + #ifdef USE_TCLX |
| 137 | + TclX_Main(argc, argv, Tcl_AppInit); |
| 138 | +--- a/contrib/ldaptcl/tkAppInit.c |
| 139 | ++++ b/contrib/ldaptcl/tkAppInit.c |
| 140 | +@@ -37,16 +37,9 @@ int (*tclDummyMathPtr)() = matherr; |
| 141 | + * This is the main program for the application. |
| 142 | + *----------------------------------------------------------------------------- |
| 143 | + */ |
| 144 | +-#ifdef __cplusplus |
| 145 | + int |
| 146 | + main (int argc, |
| 147 | + char **argv) |
| 148 | +-#else |
| 149 | +-int |
| 150 | +-main (argc, argv) |
| 151 | +- int argc; |
| 152 | +- char **argv; |
| 153 | +-#endif |
| 154 | + { |
| 155 | + #ifdef USE_TCLX |
| 156 | + TkX_Main(argc, argv, Tcl_AppInit); |
| 157 | +@@ -68,14 +61,8 @@ main (argc, argv) |
| 158 | + * interp->result if an error occurs. |
| 159 | + *----------------------------------------------------------------------------- |
| 160 | + */ |
| 161 | +-#ifdef __cplusplus |
| 162 | + int |
| 163 | + Tcl_AppInit (Tcl_Interp *interp) |
| 164 | +-#else |
| 165 | +-int |
| 166 | +-Tcl_AppInit (interp) |
| 167 | +- Tcl_Interp *interp; |
| 168 | +-#endif |
| 169 | + { |
| 170 | + if (Tcl_Init (interp) == TCL_ERROR) { |
| 171 | + return TCL_ERROR; |
| 172 | +--- a/servers/slapd/syslog.c |
| 173 | ++++ b/servers/slapd/syslog.c |
| 174 | +@@ -209,7 +209,7 @@ openlog(const char *ident, int logstat, int logfac) |
| 175 | + } |
| 176 | + |
| 177 | + void |
| 178 | +-closelog() |
| 179 | ++closelog(void) |
| 180 | + { |
| 181 | + (void)close(LogFile); |
| 182 | + LogFile = -1; |
| 183 | +-- |
| 184 | +2.38.1 |
| 185 | + |
0 commit comments