*/*.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 GH-10751
This commit is contained in:
Michael Orlitzky 2023-03-03 12:16:14 -05:00 committed by George Peter Banyard
parent 3f7dadfeca
commit fa65873502
7 changed files with 32 additions and 32 deletions

View file

@ -73,7 +73,7 @@ void *thread_routine(void *data) {
return data;
}
int main() {
int main(void) {
pthread_t thd;
pthread_mutexattr_t mattr;
int data = 1;

View file

@ -162,7 +162,7 @@ int stack_grows_downwards(uintptr_t arg) {
return (uintptr_t)&local < arg;
}
int main() {
int main(void) {
int local;
f = stack_grows_downwards;
@ -250,7 +250,7 @@ typedef union _mm_align_test {
#define ZEND_MM_ALIGNMENT (sizeof(mm_align_test))
#endif
int main()
int main(void)
{
size_t i = ZEND_MM_ALIGNMENT;
int zeros = 0;

View file

@ -1034,7 +1034,7 @@ AC_DEFUN([_PHP_CHECK_SIZEOF], [
#endif
$3
int main()
int main(void)
{
FILE *fp = fopen("conftestval", "w");
if (!fp) return(1);
@ -1102,7 +1102,7 @@ AC_CACHE_CHECK(for type of reentrant time-related functions, ac_cv_time_r_type,[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <time.h>
int main() {
int main(void) {
char buf[27];
struct tm t;
time_t old = 0;
@ -1118,7 +1118,7 @@ return (1);
],[
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <time.h>
int main() {
int main(void) {
struct tm t, *s;
time_t old = 0;
char buf[27], *p;
@ -1159,7 +1159,7 @@ AC_DEFUN([PHP_DOES_PWRITE_WORK],[
#include <errno.h>
#include <stdlib.h>
$1
int main() {
int main(void) {
int fd = open("conftest_in", O_WRONLY|O_CREAT, 0600);
if (fd < 0) return 1;
@ -1193,7 +1193,7 @@ AC_DEFUN([PHP_DOES_PREAD_WORK],[
#include <errno.h>
#include <stdlib.h>
$1
int main() {
int main(void) {
char buf[3];
int fd = open("conftest_in", O_RDONLY);
if (fd < 0) return 1;
@ -1405,7 +1405,7 @@ struct s
int i;
char c[1];
};
int main()
int main(void)
{
struct s *s = malloc(sizeof(struct s) + 3);
s->i = 3;
@ -1463,7 +1463,7 @@ int seeker(void *cookie, off64_t *position, int whence)
cookie_io_functions_t funcs = {reader, writer, seeker, closer};
int main() {
int main(void) {
struct cookiedata g = { 0 };
FILE *fp = fopencookie(&g, "r", funcs);
@ -1590,7 +1590,7 @@ AC_DEFUN([PHP_CHECK_FUNC_LIB],[
if test "$found" = "yes"; then
ac_libs=$LIBS
LIBS="$LIBS -l$2"
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main() { return (0); }]])],[found=yes],[found=no],[
AC_RUN_IFELSE([AC_LANG_SOURCE([[int main(void) { return (0); }]])],[found=yes],[found=no],[
dnl Cross compilation.
found=yes
])
@ -1644,7 +1644,7 @@ AC_DEFUN([PHP_TEST_BUILD], [
AC_LINK_IFELSE([AC_LANG_SOURCE([[
$5
char $1();
int main() {
int main(void) {
$1();
return 0;
}
@ -2296,7 +2296,7 @@ AC_DEFUN([PHP_TEST_WRITE_STDOUT],[
#define TEXT "This is the test message -- "
int main()
int main(void)
{
int n;
@ -2818,7 +2818,7 @@ AC_DEFUN([PHP_CHECK_AVX512_SUPPORTS], [
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <immintrin.h>
int main() {
int main(void) {
__m512i mask = _mm512_set1_epi32(0x1);
char out[32];
_mm512_storeu_si512(out, _mm512_shuffle_epi8(mask, mask));
@ -2846,7 +2846,7 @@ AC_DEFUN([PHP_CHECK_AVX512_VBMI_SUPPORTS], [
CFLAGS="-mavx512f -mavx512cd -mavx512vl -mavx512dq -mavx512bw -mavx512vbmi $CFLAGS"
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <immintrin.h>
int main() {
int main(void) {
__m512i mask = _mm512_set1_epi32(0x1);
char out[32];
_mm512_storeu_si512(out, _mm512_permutexvar_epi8(mask, mask));

View file

@ -30,7 +30,7 @@ if test "$PHP_ICONV" != "no"; then
AC_MSG_CHECKING([if using GNU libiconv])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <iconv.h>
int main() {
int main(void) {
printf("%d", _libiconv_version);
return 0;
}
@ -90,7 +90,7 @@ int main() {
#include <iconv.h>
#include <errno.h>
int main() {
int main(void) {
iconv_t cd;
cd = iconv_open( "*blahblah*", "*blahblahblah*" );
if (cd == (iconv_t)(-1)) {
@ -117,7 +117,7 @@ int main() {
#include <iconv.h>
#include <stdlib.h>
int main() {
int main(void) {
iconv_t cd = iconv_open( "UTF-8//IGNORE", "UTF-8" );
if(cd == (iconv_t)-1) {
return 1;

View file

@ -116,7 +116,7 @@ if test "$PHP_OPCACHE" != "no"; then
#include <unistd.h>
#include <string.h>
int main() {
int main(void) {
pid_t pid;
int status;
int ipc_id;
@ -195,7 +195,7 @@ int main() {
# define MAP_FAILED ((void*)-1)
#endif
int main() {
int main(void) {
pid_t pid;
int status;
char *shm;
@ -257,7 +257,7 @@ int main() {
# define MAP_FAILED ((void*)-1)
#endif
int main() {
int main(void) {
pid_t pid;
int status;
int fd;

View file

@ -81,7 +81,7 @@ if test "$PHP_EXTERNAL_LIBCRYPT" != "no"; then
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char *encrypted = crypt("rasmuslerdorf","rl");
return !encrypted || strcmp(encrypted,"rl.3StKT.4T8M");
@ -111,7 +111,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char *encrypted = crypt("rasmuslerdorf","_J9..rasm");
return !encrypted || strcmp(encrypted,"_J9..rasmBYk8r9AiWNc");
@ -141,7 +141,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char salt[15], answer[40];
char *encrypted;
@ -181,7 +181,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char salt[30], answer[70];
char *encrypted;
@ -218,7 +218,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char salt[21], answer[21+86];
char *encrypted;
@ -254,7 +254,7 @@ int main() {
#include <stdlib.h>
#include <string.h>
int main() {
int main(void) {
#if HAVE_CRYPT
char salt[21], answer[21+43];
char *encrypted;

View file

@ -66,7 +66,7 @@ AC_DEFUN([AC_FPM_CLOCK],
#include <mach/clock.h>
#include <mach/mach_error.h>
int main()
int main(void)
{
kern_return_t ret; clock_serv_t aClock; mach_timespec_t aTime;
ret = host_get_clock_service(mach_host_self(), REALTIME_CLOCK, &aClock);
@ -134,7 +134,7 @@ AC_DEFUN([AC_FPM_TRACE],
#define PTRACE_PEEKDATA PT_READ_D
#endif
int main()
int main(void)
{
long v1 = (unsigned int) -1; /* copy will fail if sizeof(long) == 8 and we've got "int ptrace()" */
long v2;
@ -239,7 +239,7 @@ AC_DEFUN([AC_FPM_TRACE],
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
int main()
int main(void)
{
long v1 = (unsigned int) -1, v2 = 0;
char buf[128];
@ -578,7 +578,7 @@ if test "$PHP_FPM" != "no"; then
AC_CHECK_HEADERS([sys/acl.h])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
int main()
int main(void)
{
acl_t acl;
acl_entry_t user, group;
@ -597,7 +597,7 @@ if test "$PHP_FPM" != "no"; then
AC_MSG_RESULT([yes])
],[
AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/acl.h>
int main()
int main(void)
{
acl_t acl;
acl_entry_t user, group;