Skip to content

Commit fa65873

Browse files
orlitzkyGirgias
authored andcommitted
*/*.m4: update main() signatures.
The next generation of C compilers is going to enforce the C standard more strictly: https://wiki.gentoo.org/wiki/Modern_C_porting One warning that will soon become an error is -Wstrict-prototypes. This is relatively easy to catch in most code (it will fail to compile), but inside of autoconf tests it can go unnoticed because many feature-test compilations fail by design. For example, $ export CFLAGS="$CFLAGS -Werror=strict-prototypes" $ ./configure ... checking if iconv supports errno... no configure: error: iconv does not support errno (this is on a system where iconv *does* support errno). If errno support were optional, that test would have "silently" disabled it. The underlying issue here, from config.log, is conftest.c:211:5: error: function declaration isn't a prototype [-Werror=strict-prototypes] 211 | int main() { This commit goes through all of our autoconf tests, replacing main() with main(void). Up to equivalent types and variable renamings, that's one of the two valid signatures, and satisfies the compiler (gcc-12 in this case). Fixes phpGH-10751
1 parent 3f7dadf commit fa65873

File tree

7 files changed

+32
-32
lines changed

7 files changed

+32
-32
lines changed

TSRM/threads.m4

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ int stack_grows_downwards(uintptr_t arg) {
162162
return (uintptr_t)&local < arg;
163163
}
164164
165-
int main() {
165+
int main(void) {
166166
int local;
167167
168168
f = stack_grows_downwards;
@@ -250,7 +250,7 @@ typedef union _mm_align_test {
250250
#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
251251
#endif
252252
253-
int main()
253+
int main(void)
254254
{
255255
size_t i = ZEND_MM_ALIGNMENT;
256256
int zeros = 0;

build/php.m4

Lines changed: 12 additions & 12 deletions
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;
@@ -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_SOURCE([[int main(void) { return (0); }]])],[found=yes],[found=no],[
15941594
dnl Cross compilation.
15951595
found=yes
15961596
])
@@ -1644,7 +1644,7 @@ AC_DEFUN([PHP_TEST_BUILD], [
16441644
AC_LINK_IFELSE([AC_LANG_SOURCE([[
16451645
$5
16461646
char $1();
1647-
int main() {
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
@@ -2818,7 +2818,7 @@ AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [
28182818
28192819
AC_LINK_IFELSE([AC_LANG_SOURCE([[
28202820
#include <immintrin.h>
2821-
int main() {
2821+
int main(void) {
28222822
__m512i mask = _mm512_set1_epi32(0x1);
28232823
char out[32];
28242824
_mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
@@ -2846,7 +2846,7 @@ AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
28462846
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
28472847
AC_LINK_IFELSE([AC_LANG_SOURCE([[
28482848
#include <immintrin.h>
2849-
int main() {
2849+
int main(void) {
28502850
__m512i mask = _mm512_set1_epi32(0x1);
28512851
char out[32];
28522852
_mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));

ext/iconv/config.m4

Lines changed: 3 additions & 3 deletions
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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ if test "$PHP_OPCACHE" != "no"; then
116116
#include <unistd.h>
117117
#include <string.h>
118118
119-
int main() {
119+
int main(void) {
120120
pid_t pid;
121121
int status;
122122
int ipc_id;
@@ -195,7 +195,7 @@ int main() {
195195
# define MAP_FAILED ((void*)-1)
196196
#endif
197197
198-
int main() {
198+
int main(void) {
199199
pid_t pid;
200200
int status;
201201
char *shm;
@@ -257,7 +257,7 @@ int main() {
257257
# define MAP_FAILED ((void*)-1)
258258
#endif
259259
260-
int main() {
260+
int main(void) {
261261
pid_t pid;
262262
int status;
263263
int fd;

ext/standard/config.m4

Lines changed: 6 additions & 6 deletions
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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ AC_DEFUN([AC_FPM_CLOCK],
6666
#include <mach/clock.h>
6767
#include <mach/mach_error.h>
6868
69-
int main()
69+
int main(void)
7070
{
7171
kern_return_t ret; clock_serv_t aClock; mach_timespec_t aTime;
7272
ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &aClock);
@@ -134,7 +134,7 @@ AC_DEFUN([AC_FPM_TRACE],
134134
#define PTRACE_PEEKDATA PT_READ_D
135135
#endif
136136
137-
int main()
137+
int main(void)
138138
{
139139
long v1 = (unsigned int) -1; /* copy will fail if sizeof(long) == 8 and we've got "int ptrace()" */
140140
long v2;
@@ -239,7 +239,7 @@ AC_DEFUN([AC_FPM_TRACE],
239239
#include <sys/stat.h>
240240
#include <fcntl.h>
241241
#include <stdio.h>
242-
int main()
242+
int main(void)
243243
{
244244
long v1 = (unsigned int) -1, v2 = 0;
245245
char buf[128];
@@ -578,7 +578,7 @@ if test "$PHP_FPM" != "no"; then
578578
AC_CHECK_HEADERS([sys/acl.h])
579579

580580
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
581-
int main()
581+
int main(void)
582582
{
583583
acl_t acl;
584584
acl_entry_t user, group;
@@ -597,7 +597,7 @@ if test "$PHP_FPM" != "no"; then
597597
AC_MSG_RESULT([yes])
598598
],[
599599
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
600-
int main()
600+
int main(void)
601601
{
602602
acl_t acl;
603603
acl_entry_t user, group;

0 commit comments

Comments
 (0)