Skip to content

Commit 868257a

Browse files
committed
Fix phpGH-13727: macro generating invalid call test prototypes fixes.
autoconf/libtool generating code to test features missed `void` for C calls prototypes w/o arguments. Note that specific changes related to libtool have to be upstreamed. Co-authored-by: Peter Kokot <petk@php.net> close phpGH-13732
1 parent aa34e0a commit 868257a

File tree

12 files changed

+47
-45
lines changed

12 files changed

+47
-45
lines changed

NEWS

+2
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ PHP NEWS
151151
loading composer classmaps with more than 11k elements). (nielsdos)
152152
. Fixed bug GH-12966 (missing cross-compiling 3rd argument so Autoconf doesn't
153153
emit warnings). (Peter Kokot)
154+
. Fixed bug GH-13727 (missing void keyword for C generate code for feature test).
155+
(Peter Kokot/David Carlier)
154156

155157
- Cli:
156158
. Fix incorrect timeout in built-in web server when using router script and

TSRM/threads.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void *thread_routine(void *data) {
7373
return data;
7474
}
7575
76-
int main() {
76+
int main(void) {
7777
pthread_t thd;
7878
pthread_mutexattr_t mattr;
7979
int data = 1;

Zend/Zend.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ typedef union _mm_align_test {
220220
#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
221221
#endif
222222
223-
int main()
223+
int main(void)
224224
{
225225
size_t i = ZEND_MM_ALIGNMENT;
226226
int zeros = 0;

build/libtool.m4

+5-5
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ dnl This sometimes fails to find confdefs.h, for some reason.
277277
dnl [#]line __oline__ "[$]0"
278278
[#]line __oline__ "configure"
279279
#include "confdefs.h"
280-
int main() {
280+
int main(void) {
281281
; return 0; }
282282
EOF
283283
if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
@@ -978,8 +978,8 @@ else
978978
# endif
979979
#endif
980980
981-
void fnord() { int i=42;}
982-
int main ()
981+
void fnord(void) { int i=42;}
982+
int main (void)
983983
{
984984
void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
985985
int status = $lt_dlunknown;
@@ -2750,7 +2750,7 @@ _LT_AC_TAGVAR(objext, $1)=$objext
27502750
lt_simple_compile_test_code="int some_variable = 0;"
27512751
27522752
# Code to be used in simple link tests
2753-
lt_simple_link_test_code='int main(){return(0);}'
2753+
lt_simple_link_test_code='int main(void){return(0);}'
27542754
27552755
_LT_AC_SYS_COMPILER
27562756
@@ -4640,7 +4640,7 @@ void nm_test_func(){}
46404640
#ifdef __cplusplus
46414641
}
46424642
#endif
4643-
int main(){nm_test_var='a';nm_test_func();return(0);}
4643+
int main(void){nm_test_var='a';nm_test_func();return(0);}
46444644
EOF
46454645
46464646
if AC_TRY_EVAL(ac_compile); then

build/ltmain.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -3598,7 +3598,7 @@ EOF
35983598
# whether they linked in statically or dynamically with ldd.
35993599
$rm conftest.c
36003600
cat > conftest.c <<EOF
3601-
int main() { return 0; }
3601+
int main(void) { return 0; }
36023602
EOF
36033603
$rm conftest
36043604
if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then

build/php.m4

+17-17
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ AC_DEFUN([_PHP_CHECK_SIZEOF], [
10341034
#endif
10351035
$3
10361036
1037-
int main()
1037+
int main(void)
10381038
{
10391039
FILE *fp = fopen("conftestval", "w");
10401040
if (!fp) return(1);
@@ -1102,7 +1102,7 @@ AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
11021102
AC_RUN_IFELSE([AC_LANG_SOURCE([[
11031103
#include <time.h>
11041104
1105-
int main() {
1105+
int main(void) {
11061106
char buf[27];
11071107
struct tm t;
11081108
time_t old = 0;
@@ -1118,7 +1118,7 @@ return (1);
11181118
],[
11191119
AC_RUN_IFELSE([AC_LANG_SOURCE([[
11201120
#include <time.h>
1121-
int main() {
1121+
int main(void) {
11221122
struct tm t, *s;
11231123
time_t old = 0;
11241124
char buf[27], *p;
@@ -1159,7 +1159,7 @@ AC_DEFUN([PHP_DOES_PWRITE_WORK],[
11591159
#include <errno.h>
11601160
#include <stdlib.h>
11611161
$1
1162-
int main() {
1162+
int main(void) {
11631163
int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
11641164
11651165
if (fd < 0) return 1;
@@ -1193,7 +1193,7 @@ AC_DEFUN([PHP_DOES_PREAD_WORK],[
11931193
#include <errno.h>
11941194
#include <stdlib.h>
11951195
$1
1196-
int main() {
1196+
int main(void) {
11971197
char buf[3];
11981198
int fd = open("conftest_in", O_RDONLY);
11991199
if (fd < 0) return 1;
@@ -1261,27 +1261,27 @@ dnl PHP_MISSING_TIME_R_DECL
12611261
dnl
12621262
AC_DEFUN([PHP_MISSING_TIME_R_DECL],[
12631263
AC_MSG_CHECKING([for missing declarations of reentrant functions])
1264-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = localtime_r]])],[
1264+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)(void) = localtime_r]])],[
12651265
:
12661266
],[
12671267
AC_DEFINE(MISSING_LOCALTIME_R_DECL,1,[Whether localtime_r is declared])
12681268
])
1269-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)() = gmtime_r]])],[
1269+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[struct tm *(*func)(void) = gmtime_r]])],[
12701270
:
12711271
],[
12721272
AC_DEFINE(MISSING_GMTIME_R_DECL,1,[Whether gmtime_r is declared])
12731273
])
1274-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = asctime_r]])],[
1274+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)(void) = asctime_r]])],[
12751275
:
12761276
],[
12771277
AC_DEFINE(MISSING_ASCTIME_R_DECL,1,[Whether asctime_r is declared])
12781278
])
1279-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)() = ctime_r]])],[
1279+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[char *(*func)(void) = ctime_r]])],[
12801280
:
12811281
],[
12821282
AC_DEFINE(MISSING_CTIME_R_DECL,1,[Whether ctime_r is declared])
12831283
])
1284-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)() = strtok_r]])],[
1284+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <string.h>]], [[char *(*func)(void) = strtok_r]])],[
12851285
:
12861286
],[
12871287
AC_DEFINE(MISSING_STRTOK_R_DECL,1,[Whether strtok_r is declared])
@@ -1315,7 +1315,7 @@ dnl See if we have broken header files like SunOS has.
13151315
dnl
13161316
AC_DEFUN([PHP_MISSING_FCLOSE_DECL],[
13171317
AC_MSG_CHECKING([for fclose declaration])
1318-
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[int (*func)() = fclose]])],[
1318+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [[int (*func)(void) = fclose]])],[
13191319
AC_DEFINE(MISSING_FCLOSE_DECL,0,[ ])
13201320
AC_MSG_RESULT([ok])
13211321
],[
@@ -1405,7 +1405,7 @@ struct s
14051405
int i;
14061406
char c[1];
14071407
};
1408-
int main()
1408+
int main(void)
14091409
{
14101410
struct s *s = malloc(sizeof(struct s) + 3);
14111411
s->i = 3;
@@ -1463,7 +1463,7 @@ int seeker(void *cookie, off64_t *position, int whence)
14631463
14641464
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
14651465
1466-
int main() {
1466+
int main(void) {
14671467
struct cookiedata g = { 0 };
14681468
FILE *fp = fopencookie(&g, "r", funcs);
14691469
@@ -1590,7 +1590,7 @@ AC_DEFUN([PHP_CHECK_FUNC_LIB],[
15901590
if test "$found" = "yes"; then
15911591
ac_libs=$LIBS
15921592
LIBS="$LIBS -l$2"
1593-
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return (0); }]])],[found=yes],[found=no],[
1593+
AC_RUN_IFELSE([AC_LANG_PROGRAM()],[found=yes],[found=no],[
15941594
dnl Cross compilation.
15951595
found=yes
15961596
])
@@ -1643,8 +1643,8 @@ AC_DEFUN([PHP_TEST_BUILD], [
16431643
LIBS="$4 $LIBS"
16441644
AC_LINK_IFELSE([AC_LANG_SOURCE([[
16451645
$5
1646-
char $1();
1647-
int main() {
1646+
char $1(void);
1647+
int main(void) {
16481648
$1();
16491649
return 0;
16501650
}
@@ -2296,7 +2296,7 @@ AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
22962296
22972297
#define TEXT "This is the test message -- "
22982298
2299-
int main()
2299+
int main(void)
23002300
{
23012301
int n;
23022302

configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ case $host_alias in
11201120
save_LDFLAGS=$LDFLAGS
11211121
LDFLAGS="$LDFLAGS -Wl,-zcommon-page-size=2097152 -Wl,-zmax-page-size=2097152"
11221122
AC_RUN_IFELSE(
1123-
[AC_LANG_SOURCE([[int main() {return 0;}]])],
1123+
[AC_LANG_PROGRAM()],
11241124
[ac_cv_common_page_size=yes],
11251125
[ac_cv_common_page_size=no],
11261126
[ac_cv_common_page_size=no])
@@ -1134,7 +1134,7 @@ case $host_alias in
11341134
save_LDFLAGS=$LDFLAGS
11351135
LDFLAGS="$LDFLAGS -Wl,-zmax-page-size=2097152"
11361136
AC_RUN_IFELSE(
1137-
[AC_LANG_SOURCE([[int main() {return 0;}]])],
1137+
[AC_LANG_PROGRAM()],
11381138
[ac_cv_max_page_size=yes],
11391139
[ac_cv_max_page_size=no],
11401140
[ac_cv_max_page_size=no])

ext/gd/config.m4

+1-1
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ dnl Various checks for GD features
239239

240240
PHP_TEST_BUILD(foobar, [], [
241241
AC_MSG_ERROR([GD build test failed. Please check the config.log for details.])
242-
], [ $GD_SHARED_LIBADD ], [char foobar () {}])
242+
], [ $GD_SHARED_LIBADD ], [char foobar (void) {}])
243243

244244
else
245245
extra_sources="gd_compat.c"

ext/iconv/config.m4

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ if test "$PHP_ICONV" != "no"; then
3030
AC_MSG_CHECKING([if using GNU libiconv])
3131
AC_RUN_IFELSE([AC_LANG_SOURCE([[
3232
#include <iconv.h>
33-
int main() {
33+
int main(void) {
3434
printf("%d", _libiconv_version);
3535
return 0;
3636
}
@@ -90,7 +90,7 @@ int main() {
9090
#include <iconv.h>
9191
#include <errno.h>
9292
93-
int main() {
93+
int main(void) {
9494
iconv_t cd;
9595
cd = iconv_open( "*blahblah*", "*blahblahblah*" );
9696
if (cd == (iconv_t)(-1)) {
@@ -117,7 +117,7 @@ int main() {
117117
#include <iconv.h>
118118
#include <stdlib.h>
119119
120-
int main() {
120+
int main(void) {
121121
iconv_t cd = iconv_open( "UTF-8//IGNORE", "UTF-8" );
122122
if(cd == (iconv_t)-1) {
123123
return 1;

ext/opcache/config.m4

+3-3
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ if test "$PHP_OPCACHE" != "no"; then
121121
#include <unistd.h>
122122
#include <string.h>
123123
124-
int main() {
124+
int main(void) {
125125
pid_t pid;
126126
int status;
127127
int ipc_id;
@@ -200,7 +200,7 @@ int main() {
200200
# define MAP_FAILED ((void*)-1)
201201
#endif
202202
203-
int main() {
203+
int main(void) {
204204
pid_t pid;
205205
int status;
206206
char *shm;
@@ -262,7 +262,7 @@ int main() {
262262
# define MAP_FAILED ((void*)-1)
263263
#endif
264264
265-
int main() {
265+
int main(void) {
266266
pid_t pid;
267267
int status;
268268
int fd;

ext/standard/config.m4

+6-6
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ if test "$PHP_EXTERNAL_LIBCRYPT" != "no"; then
8181
#include <stdlib.h>
8282
#include <string.h>
8383
84-
int main() {
84+
int main(void) {
8585
#if HAVE_CRYPT
8686
char *encrypted = crypt("rasmuslerdorf","rl");
8787
return !encrypted || strcmp(encrypted,"rl.3StKT.4T8M");
@@ -111,7 +111,7 @@ int main() {
111111
#include <stdlib.h>
112112
#include <string.h>
113113
114-
int main() {
114+
int main(void) {
115115
#if HAVE_CRYPT
116116
char *encrypted = crypt("rasmuslerdorf","_J9..rasm");
117117
return !encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc");
@@ -141,7 +141,7 @@ int main() {
141141
#include <stdlib.h>
142142
#include <string.h>
143143
144-
int main() {
144+
int main(void) {
145145
#if HAVE_CRYPT
146146
char salt[15], answer[40];
147147
char *encrypted;
@@ -181,7 +181,7 @@ int main() {
181181
#include <stdlib.h>
182182
#include <string.h>
183183
184-
int main() {
184+
int main(void) {
185185
#if HAVE_CRYPT
186186
char salt[30], answer[70];
187187
char *encrypted;
@@ -218,7 +218,7 @@ int main() {
218218
#include <stdlib.h>
219219
#include <string.h>
220220
221-
int main() {
221+
int main(void) {
222222
#if HAVE_CRYPT
223223
char salt[21], answer[21+86];
224224
char *encrypted;
@@ -254,7 +254,7 @@ int main() {
254254
#include <stdlib.h>
255255
#include <string.h>
256256
257-
int main() {
257+
int main(void) {
258258
#if HAVE_CRYPT
259259
char salt[21], answer[21+43];
260260
char *encrypted;

sapi/fpm/config.m4

+5-5
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ AC_DEFUN([AC_FPM_CLOCK],
9090
#include <mach/clock.h>
9191
#include <mach/mach_error.h>
9292
93-
int main()
93+
int main(void)
9494
{
9595
kern_return_t ret; clock_serv_t aClock; mach_timespec_t aTime;
9696
ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &aClock);
@@ -158,7 +158,7 @@ AC_DEFUN([AC_FPM_TRACE],
158158
#define PTRACE_PEEKDATA PT_READ_D
159159
#endif
160160
161-
int main()
161+
int main(void)
162162
{
163163
long v1 = (unsigned int) -1; /* copy will fail if sizeof(long) == 8 and we've got "int ptrace()" */
164164
long v2;
@@ -263,7 +263,7 @@ AC_DEFUN([AC_FPM_TRACE],
263263
#include <sys/stat.h>
264264
#include <fcntl.h>
265265
#include <stdio.h>
266-
int main()
266+
int main(void)
267267
{
268268
long v1 = (unsigned int) -1, v2 = 0;
269269
char buf[128];
@@ -604,7 +604,7 @@ if test "$PHP_FPM" != "no"; then
604604
AC_CHECK_HEADERS([sys/acl.h])
605605

606606
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
607-
int main()
607+
int main(void)
608608
{
609609
acl_t acl;
610610
acl_entry_t user, group;
@@ -623,7 +623,7 @@ if test "$PHP_FPM" != "no"; then
623623
AC_MSG_RESULT([yes])
624624
],[
625625
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
626-
int main()
626+
int main(void)
627627
{
628628
acl_t acl;
629629
acl_entry_t user, group;

0 commit comments

Comments
 (0)