From 33194c31fa0b340ffa55c33b41be0207aeb6596e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 22 Jul 2020 18:59:32 +0100 Subject: [PATCH 01/14] Add -Wstrict-prototypes compiler warning --- Zend/Zend.m4 | 1 + 1 file changed, 1 insertion(+) diff --git a/Zend/Zend.m4 b/Zend/Zend.m4 index bbfc3985a7b61..ca6768d2d6c54 100644 --- a/Zend/Zend.m4 +++ b/Zend/Zend.m4 @@ -214,6 +214,7 @@ AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough=1], CFLAGS="$CFLAGS -Wimplicit-fal AX_CHECK_COMPILE_FLAG([-Wduplicated-cond], CFLAGS="-Wduplicated-cond $CFLAGS", , [-Werror]) AX_CHECK_COMPILE_FLAG([-Wlogical-op], CFLAGS="-Wlogical-op $CFLAGS", , [-Werror]) AX_CHECK_COMPILE_FLAG([-Wformat-truncation], CFLAGS="-Wformat-truncation $CFLAGS", , [-Werror]) +AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes], CFLAGS="-Wstrict-prototypes $CFLAGS", , [-Werror]) AX_CHECK_COMPILE_FLAG([-fno-common], CFLAGS="-fno-common $CFLAGS", , [-Werror]) test -n "$DEBUG_CFLAGS" && CFLAGS="$CFLAGS $DEBUG_CFLAGS" From 8f91638ab3395eca20a85258902f26b2b4f873f6 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 29 Jul 2020 20:54:39 +0100 Subject: [PATCH 02/14] Fix [-Wstrict-prototypes] warning in Intl extension --- ext/intl/collator/collator_is_numeric.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.c index 3cda24291b990..82a59ee7aaaf4 100644 --- a/ext/intl/collator/collator_is_numeric.c +++ b/ext/intl/collator/collator_is_numeric.c @@ -110,10 +110,7 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */ * * Ignores `locale' stuff. */ -static zend_long collator_u_strtol(nptr, endptr, base) - const UChar *nptr; - UChar **endptr; - register int base; +static zend_long collator_u_strtol(const UChar *nptr, UChar **endptr, register int base) { register const UChar *s = nptr; register zend_ulong acc; From 35801504de2183520b40f4ba310c4f9212ee7925 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 30 Jul 2020 03:09:27 +0100 Subject: [PATCH 03/14] Fix [-Wstrict-prototypes] in Readline extension --- ext/readline/readline_cli.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c index d6116711276d4..7a0fe78595e5b 100644 --- a/ext/readline/readline_cli.c +++ b/ext/readline/readline_cli.c @@ -743,7 +743,7 @@ this extension sharedto offer compatibility. #define GET_SHELL_CB(cb) \ do { \ (cb) = NULL; \ - cli_shell_callbacks_t *(*get_callbacks)(); \ + cli_shell_callbacks_t *(*get_callbacks)(void); \ get_callbacks = dlsym(RTLD_DEFAULT, "php_cli_get_shell_callbacks"); \ if (get_callbacks) { \ (cb) = get_callbacks(); \ From 19332883013b6d6b3a83c278e95cfa60bfd92f97 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 14:41:11 +0100 Subject: [PATCH 04/14] Fix [-Wstrict-prototypes] in standard/scanf.c --- ext/standard/scanf.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index f58b4195cc599..90157267a8af3 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -583,7 +583,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, int base = 0; int underflow = 0; size_t width; - zend_long (*fn)() = NULL; + zend_long (*fn)(const char*, char**, int) = NULL; char *ch, sch; int flags; char buf[64]; /* Temporary buffer to hold scanned number @@ -740,29 +740,29 @@ PHPAPI int php_sscanf_internal( char *string, char *format, case 'D': op = 'i'; base = 10; - fn = (zend_long (*)())ZEND_STRTOL_PTR; + fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; break; case 'i': op = 'i'; base = 0; - fn = (zend_long (*)())ZEND_STRTOL_PTR; + fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; break; case 'o': op = 'i'; base = 8; - fn = (zend_long (*)())ZEND_STRTOL_PTR; + fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; break; case 'x': case 'X': op = 'i'; base = 16; - fn = (zend_long (*)())ZEND_STRTOL_PTR; + fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; break; case 'u': op = 'i'; base = 10; flags |= SCAN_UNSIGNED; - fn = (zend_long (*)())ZEND_STRTOUL_PTR; + fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOUL_PTR; break; case 'f': From 31a260301fb55c725685a8483a1b83e6490f8e2e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Thu, 30 Jul 2020 04:26:48 +0100 Subject: [PATCH 05/14] Fix [-Wstrict-prototypes] in PCNTL extension .c files --- ext/pcntl/pcntl.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 1e8690ae75144..9d10199b2d0f9 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -89,7 +89,8 @@ static void pcntl_siginfo_to_zval(int, siginfo_t*, zval*); #else static void pcntl_signal_handler(int); #endif -static void pcntl_signal_dispatch(); +static void pcntl_signal_dispatch(void); +static void pcntl_signal_dispatch_tick_function(int dummy_int, void *dummy_pointer); static void pcntl_interrupt_function(zend_execute_data *execute_data); void php_register_signal_constants(INIT_FUNC_ARGS) @@ -424,7 +425,7 @@ static PHP_GINIT_FUNCTION(pcntl) PHP_RINIT_FUNCTION(pcntl) { - php_add_tick_function(pcntl_signal_dispatch, NULL); + php_add_tick_function(pcntl_signal_dispatch_tick_function, NULL); zend_hash_init(&PCNTL_G(php_signal_table), 16, NULL, ZVAL_PTR_DTOR, 0); PCNTL_G(head) = PCNTL_G(tail) = PCNTL_G(spares) = NULL; PCNTL_G(async_signals) = 0; @@ -1385,6 +1386,11 @@ void pcntl_signal_dispatch() sigprocmask(SIG_SETMASK, &old_mask, NULL); } +void pcntl_signal_dispatch_tick_function(int dummy_int, void *dummy_pointer) +{ + return pcntl_signal_dispatch(); +} + /* {{{ Enable/disable asynchronous signal handling and return the old setting. */ PHP_FUNCTION(pcntl_async_signals) { From dc9d72f945d0afe09211b550f71c7d16f97a87f9 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 29 Jul 2020 03:23:39 +0100 Subject: [PATCH 06/14] Add -Wno-strict-prototypes compiler flag to pspell extension --- ext/pspell/config.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/pspell/config.m4 b/ext/pspell/config.m4 index a0212165f6e8f..bd9417e75ee63 100644 --- a/ext/pspell/config.m4 +++ b/ext/pspell/config.m4 @@ -4,7 +4,8 @@ PHP_ARG_WITH([pspell], [Include PSPELL support. GNU Aspell version 0.50.0 or higher required])]) if test "$PHP_PSPELL" != "no"; then - PHP_NEW_EXTENSION(pspell, pspell.c, $ext_shared) + dnl Add -Wno-strict-prototypes as depends on user libs + PHP_NEW_EXTENSION(pspell, pspell.c, $ext_shared, , "-Wno-strict-prototypes") if test "$PHP_PSPELL" != "yes"; then PSPELL_SEARCH_DIRS=$PHP_PSPELL else From d01d78d565592744fb6f8b1582748587084deb6e Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:16:23 +0100 Subject: [PATCH 07/14] Add -Wno-strict-prototypes compiler flag to readline extension --- ext/readline/config.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/readline/config.m4 b/ext/readline/config.m4 index ed205764f2b35..209f92b6e0a76 100644 --- a/ext/readline/config.m4 +++ b/ext/readline/config.m4 @@ -137,6 +137,7 @@ elif test "$PHP_LIBEDIT" != "no"; then fi if test "$PHP_READLINE" != "no" || test "$PHP_LIBEDIT" != "no"; then - PHP_NEW_EXTENSION(readline, readline.c readline_cli.c, $ext_shared, cli) + dnl Add -Wno-strict-prototypes as depends on user libs + PHP_NEW_EXTENSION(readline, readline.c readline_cli.c, $ext_shared, cli, "-Wno-strict-prototypes") PHP_SUBST(READLINE_SHARED_LIBADD) fi From 3703b102ec0db3685625aedb9e5914165bb6aad8 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Fri, 16 Oct 2020 17:41:47 +0100 Subject: [PATCH 08/14] Add -Wno-strict-prototypes compiler flag to GD extension --- ext/gd/config.m4 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ext/gd/config.m4 b/ext/gd/config.m4 index 28390770376e2..03c61032aa2d0 100644 --- a/ext/gd/config.m4 +++ b/ext/gd/config.m4 @@ -138,7 +138,8 @@ dnl if test "$PHP_GD" != "no"; then if test "$PHP_EXTERNAL_GD" = "no"; then - GD_CFLAGS="" + dnl Disable strict prototypes as GD takes advantages of variadic function signatures for function pointers. + GD_CFLAGS="-Wno-strict-prototypes" extra_sources="libgd/gd.c libgd/gd_gd.c libgd/gd_gd2.c libgd/gd_io.c libgd/gd_io_dp.c \ libgd/gd_io_file.c libgd/gd_ss.c libgd/gd_io_ss.c libgd/gd_webp.c \ libgd/gd_png.c libgd/gd_jpeg.c libgd/gdxpm.c libgd/gdfontt.c libgd/gdfonts.c \ From 52b28df3c3903c1ee4f9ff323733ec1195878343 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:37:38 +0100 Subject: [PATCH 09/14] Remove register qualifier in Intl func delcaration --- ext/intl/collator/collator_is_numeric.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ext/intl/collator/collator_is_numeric.c b/ext/intl/collator/collator_is_numeric.c index 82a59ee7aaaf4..823fb4088d8fd 100644 --- a/ext/intl/collator/collator_is_numeric.c +++ b/ext/intl/collator/collator_is_numeric.c @@ -110,13 +110,13 @@ static double collator_u_strtod(const UChar *nptr, UChar **endptr) /* {{{ */ * * Ignores `locale' stuff. */ -static zend_long collator_u_strtol(const UChar *nptr, UChar **endptr, register int base) +static zend_long collator_u_strtol(const UChar *nptr, UChar **endptr, int base) { - register const UChar *s = nptr; - register zend_ulong acc; - register UChar c; - register zend_ulong cutoff; - register int neg = 0, any, cutlim; + const UChar *s = nptr; + zend_ulong acc; + UChar c; + zend_ulong cutoff; + int neg = 0, any, cutlim; if (s == NULL) { errno = ERANGE; From 9293d08f70d44d1cc048ab02ef59e925f2cbbc4d Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:39:41 +0100 Subject: [PATCH 10/14] Fix pcntl_signal_dispatch_tick_function() declaration --- ext/pcntl/pcntl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pcntl/pcntl.c b/ext/pcntl/pcntl.c index 9d10199b2d0f9..e51074deace93 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -1386,7 +1386,7 @@ void pcntl_signal_dispatch() sigprocmask(SIG_SETMASK, &old_mask, NULL); } -void pcntl_signal_dispatch_tick_function(int dummy_int, void *dummy_pointer) +static void pcntl_signal_dispatch_tick_function(int dummy_int, ZEND_ATTRIBUTE_UNUSED void *dummy_pointer) { return pcntl_signal_dispatch(); } From b30ddf953b16014d0289a8d786f0974e80942236 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:41:27 +0100 Subject: [PATCH 11/14] Fix indent for comment --- ext/pspell/config.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/pspell/config.m4 b/ext/pspell/config.m4 index bd9417e75ee63..db49b4fd86bb9 100644 --- a/ext/pspell/config.m4 +++ b/ext/pspell/config.m4 @@ -4,7 +4,7 @@ PHP_ARG_WITH([pspell], [Include PSPELL support. GNU Aspell version 0.50.0 or higher required])]) if test "$PHP_PSPELL" != "no"; then - dnl Add -Wno-strict-prototypes as depends on user libs + dnl Add -Wno-strict-prototypes as depends on user libs PHP_NEW_EXTENSION(pspell, pspell.c, $ext_shared, , "-Wno-strict-prototypes") if test "$PHP_PSPELL" != "yes"; then PSPELL_SEARCH_DIRS=$PHP_PSPELL From 7c277afb4ae23cc6c5a0e2c785254caf1a207a96 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:43:04 +0100 Subject: [PATCH 12/14] Fix warning in FPM fpm_event_kqueue_clean() --- sapi/fpm/fpm/events/kqueue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sapi/fpm/fpm/events/kqueue.c b/sapi/fpm/fpm/events/kqueue.c index 746f2fa1e1b04..5c7b388e78ea9 100644 --- a/sapi/fpm/fpm/events/kqueue.c +++ b/sapi/fpm/fpm/events/kqueue.c @@ -28,7 +28,7 @@ #include static int fpm_event_kqueue_init(int max); -static int fpm_event_kqueue_clean(); +static int fpm_event_kqueue_clean(void); static int fpm_event_kqueue_wait(struct fpm_event_queue_s *queue, unsigned long int timeout); static int fpm_event_kqueue_add(struct fpm_event_s *ev); static int fpm_event_kqueue_remove(struct fpm_event_s *ev); From 7343e8e349a654d31d6ca673679708f5fe15853c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:43:53 +0100 Subject: [PATCH 13/14] Disable Werror on MacOS temporarily to find issues MacOS CI build seems to find more issues then the other ones... --- azure/macos/job.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure/macos/job.yml b/azure/macos/job.yml index ed2e8d9d223e1..59ca396de7714 100644 --- a/azure/macos/job.yml +++ b/azure/macos/job.yml @@ -65,7 +65,6 @@ jobs: --with-mhash \ --with-sodium \ --enable-dba \ - --enable-werror \ --with-config-file-path=/etc \ --with-config-file-scan-dir=/etc/php.d displayName: 'Configure Build' From ee584d15250d188f26d99285582cafa54ab8d84c Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 15:51:04 +0100 Subject: [PATCH 14/14] Use typedef for function pointer in scanf --- ext/standard/scanf.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ext/standard/scanf.c b/ext/standard/scanf.c index 90157267a8af3..78ecc1642cf92 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -106,6 +106,8 @@ typedef struct CharSet { } *ranges; } CharSet; +typedef zend_long (*int_string_formater)(const char*, char**, int); + /* * Declarations for functions used only in this file. */ @@ -583,7 +585,7 @@ PHPAPI int php_sscanf_internal( char *string, char *format, int base = 0; int underflow = 0; size_t width; - zend_long (*fn)(const char*, char**, int) = NULL; + int_string_formater fn = NULL; char *ch, sch; int flags; char buf[64]; /* Temporary buffer to hold scanned number @@ -740,29 +742,29 @@ PHPAPI int php_sscanf_internal( char *string, char *format, case 'D': op = 'i'; base = 10; - fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; + fn = (int_string_formater)ZEND_STRTOL_PTR; break; case 'i': op = 'i'; base = 0; - fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; + fn = (int_string_formater)ZEND_STRTOL_PTR; break; case 'o': op = 'i'; base = 8; - fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; + fn = (int_string_formater)ZEND_STRTOL_PTR; break; case 'x': case 'X': op = 'i'; base = 16; - fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOL_PTR; + fn = (int_string_formater)ZEND_STRTOL_PTR; break; case 'u': op = 'i'; base = 10; flags |= SCAN_UNSIGNED; - fn = (zend_long (*)(const char*, char**, int))ZEND_STRTOUL_PTR; + fn = (int_string_formater)ZEND_STRTOUL_PTR; break; case 'f':