Skip to content

Enable -Wstrict-prototypes #5888

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Zend/Zend.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion azure/macos/job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion ext/gd/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
dnl Disable strict prototypes as GD takes advantages of variadic function signatures for function pointers.
dnl Disable strict prototypes as GD takes advantage of variadic function signatures for function pointers.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can gd be fixed somehow too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, because libgd does that and not the PHP implementation.

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 \
Expand Down
15 changes: 6 additions & 9 deletions ext/intl/collator/collator_is_numeric.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,13 @@ 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, 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;
Expand Down
10 changes: 8 additions & 2 deletions ext/pcntl/pcntl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1385,6 +1386,11 @@ void pcntl_signal_dispatch()
sigprocmask(SIG_SETMASK, &old_mask, NULL);
}

static void pcntl_signal_dispatch_tick_function(int dummy_int, ZEND_ATTRIBUTE_UNUSED void *dummy_pointer)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is one of these marked as unused and the other isn't? As we disable this warning, I'd not add the attribute.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because somehow I thought this function used the first param, clearly being drunk. Will remove the attribute.

{
return pcntl_signal_dispatch();
}

/* {{{ Enable/disable asynchronous signal handling and return the old setting. */
PHP_FUNCTION(pcntl_async_signals)
{
Expand Down
3 changes: 2 additions & 1 deletion ext/pspell/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion ext/readline/config.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ext/readline/readline_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(); \
Expand Down
14 changes: 8 additions & 6 deletions ext/standard/scanf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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)() = NULL;
int_string_formater fn = NULL;
char *ch, sch;
int flags;
char buf[64]; /* Temporary buffer to hold scanned number
Expand Down Expand Up @@ -740,29 +742,29 @@ PHPAPI int php_sscanf_internal( char *string, char *format,
case 'D':
op = 'i';
base = 10;
fn = (zend_long (*)())ZEND_STRTOL_PTR;
fn = (int_string_formater)ZEND_STRTOL_PTR;
break;
case 'i':
op = 'i';
base = 0;
fn = (zend_long (*)())ZEND_STRTOL_PTR;
fn = (int_string_formater)ZEND_STRTOL_PTR;
break;
case 'o':
op = 'i';
base = 8;
fn = (zend_long (*)())ZEND_STRTOL_PTR;
fn = (int_string_formater)ZEND_STRTOL_PTR;
break;
case 'x':
case 'X':
op = 'i';
base = 16;
fn = (zend_long (*)())ZEND_STRTOL_PTR;
fn = (int_string_formater)ZEND_STRTOL_PTR;
break;
case 'u':
op = 'i';
base = 10;
flags |= SCAN_UNSIGNED;
fn = (zend_long (*)())ZEND_STRTOUL_PTR;
fn = (int_string_formater)ZEND_STRTOUL_PTR;
break;

case 'f':
Expand Down
2 changes: 1 addition & 1 deletion sapi/fpm/fpm/events/kqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <errno.h>

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);
Expand Down