From f566cba0bb6bd53b1d44d5097e68201412b00f7a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 25 Nov 2021 13:16:26 +0100 Subject: [PATCH] fix [-Wstrict-prototypes] build warnings in ext/gd --- ext/gd/config.m4 | 2 -- ext/gd/gd.c | 58 ++++++++++++++++++++++++------------------------ 2 files changed, 29 insertions(+), 31 deletions(-) diff -up a/ext/gd/gd.c.proto b/ext/gd/gd.c --- a/ext/gd/gd.c.proto 2022-10-31 11:36:07.000000000 +0100 +++ b/ext/gd/gd.c 2025-02-13 12:04:07.860118321 +0100 @@ -138,9 +138,9 @@ static void php_image_filter_pixelate(IN static void php_image_filter_scatter(INTERNAL_FUNCTION_PARAMETERS); /* End Section filters declarations */ -static gdImagePtr _php_image_create_from_string (zval *Data, char *tn, gdImagePtr (*ioctx_func_p)()); -static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(), gdImagePtr (*ioctx_func_p)()); -static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()); +static gdImagePtr _php_image_create_from_string (zval *Data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr)); +static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr)); +static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn); static int _php_image_type(char data[12]); static void _php_image_convert(INTERNAL_FUNCTION_PARAMETERS, int image_type); @@ -2330,7 +2330,7 @@ static int _php_image_type (char data[12 /* {{{ _php_image_create_from_string */ -gdImagePtr _php_image_create_from_string(zval *data, char *tn, gdImagePtr (*ioctx_func_p)()) +gdImagePtr _php_image_create_from_string(zval *data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr)) { gdImagePtr im; gdIOCtx *io_ctx; @@ -2440,7 +2440,7 @@ PHP_FUNCTION(imagecreatefromstring) /* {{{ _php_image_create_from */ -static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(), gdImagePtr (*ioctx_func_p)()) +static void _php_image_create_from(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, gdImagePtr (*func_p)(FILE *), gdImagePtr (*ioctx_func_p)(gdIOCtxPtr)) { char *file; size_t file_len; @@ -2477,7 +2477,7 @@ static void _php_image_create_from(INTER if (FAILURE == php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void**)&fp, REPORT_ERRORS)) { goto out_err; } - } else if (ioctx_func_p) { + } else if (ioctx_func_p || image_type == PHP_GDIMG_TYPE_GD2PART) { /* we can create an io context */ gdIOCtx* io_ctx; zend_string *buff; @@ -2501,7 +2501,7 @@ static void _php_image_create_from(INTER } if (image_type == PHP_GDIMG_TYPE_GD2PART) { - im = (*ioctx_func_p)(io_ctx, srcx, srcy, width, height); + im = gdImageCreateFromGd2PartCtx(io_ctx, srcx, srcy, width, height); } else { im = (*ioctx_func_p)(io_ctx); } @@ -2519,7 +2519,7 @@ static void _php_image_create_from(INTER if (!im && fp) { switch (image_type) { case PHP_GDIMG_TYPE_GD2PART: - im = (*func_p)(fp, srcx, srcy, width, height); + im = gdImageCreateFromGd2Part(fp, srcx, srcy, width, height); break; #if defined(HAVE_GD_XPM) case PHP_GDIMG_TYPE_XPM: @@ -2608,7 +2608,7 @@ PHP_FUNCTION(imagecreatefromxbm) Create a new image from XPM file or URL */ PHP_FUNCTION(imagecreatefromxpm) { - _php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XPM, "XPM", gdImageCreateFromXpm, NULL); + _php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XPM, "XPM", NULL, NULL); } /* }}} */ #endif @@ -2641,7 +2641,7 @@ PHP_FUNCTION(imagecreatefromgd2) Create a new image from a given part of GD2 file or URL */ PHP_FUNCTION(imagecreatefromgd2part) { - _php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD2PART, "GD2", gdImageCreateFromGd2Part, gdImageCreateFromGd2PartCtx); + _php_image_create_from(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD2PART, "GD2", NULL, NULL); } /* }}} */ @@ -2667,7 +2667,7 @@ PHP_FUNCTION(imagecreatefromtga) /* {{{ _php_image_output */ -static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()) +static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn) { zval *imgind; char *file = NULL; @@ -2720,13 +2720,13 @@ static void _php_image_output(INTERNAL_F gdImageWBMP(im, q, fp); break; case PHP_GDIMG_TYPE_GD: - (*func_p)(im, fp); + gdImageGd(im, fp); break; case PHP_GDIMG_TYPE_GD2: if (q == -1) { q = 128; } - (*func_p)(im, fp, q, t); + gdImageGd2(im, fp, q, t); break; default: ZEND_ASSERT(0); @@ -2756,13 +2756,13 @@ static void _php_image_output(INTERNAL_F gdImageWBMP(im, q, tmp); break; case PHP_GDIMG_TYPE_GD: - (*func_p)(im, tmp); + gdImageGd(im, tmp); break; case PHP_GDIMG_TYPE_GD2: if (q == -1) { q = 128; } - (*func_p)(im, tmp, q, t); + gdImageGd2(im, tmp, q, t); break; default: ZEND_ASSERT(0); @@ -2786,7 +2786,7 @@ static void _php_image_output(INTERNAL_F Output XBM image to browser or file */ PHP_FUNCTION(imagexbm) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XBM, "XBM", gdImageXbmCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_XBM, "XBM"); } /* }}} */ @@ -2794,7 +2794,7 @@ PHP_FUNCTION(imagexbm) Output GIF image to browser or file */ PHP_FUNCTION(imagegif) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GIF, "GIF", gdImageGifCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GIF, "GIF"); } /* }}} */ @@ -2803,7 +2803,7 @@ PHP_FUNCTION(imagegif) Output PNG image to browser or file */ PHP_FUNCTION(imagepng) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "PNG", gdImagePngCtxEx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_PNG, "PNG"); } /* }}} */ #endif /* HAVE_GD_PNG */ @@ -2814,7 +2814,7 @@ PHP_FUNCTION(imagepng) Output WEBP image to browser or file */ PHP_FUNCTION(imagewebp) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WEBP, "WEBP", gdImageWebpCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WEBP, "WEBP"); } /* }}} */ #endif /* HAVE_GD_WEBP */ @@ -2825,7 +2825,7 @@ PHP_FUNCTION(imagewebp) Output JPEG image to browser or file */ PHP_FUNCTION(imagejpeg) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_JPG, "JPEG", gdImageJpegCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_JPG, "JPEG"); } /* }}} */ #endif /* HAVE_GD_JPG */ @@ -2834,7 +2834,7 @@ PHP_FUNCTION(imagejpeg) Output WBMP image to browser or file */ PHP_FUNCTION(imagewbmp) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "WBMP", gdImageWBMPCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_WBM, "WBMP"); } /* }}} */ @@ -2842,7 +2842,7 @@ PHP_FUNCTION(imagewbmp) Output GD image to browser or file */ PHP_FUNCTION(imagegd) { - _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD, "GD", gdImageGd); + _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD, "GD"); } /* }}} */ @@ -2850,7 +2850,7 @@ PHP_FUNCTION(imagegd) Output GD2 image to browser or file */ PHP_FUNCTION(imagegd2) { - _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD2, "GD2", gdImageGd2); + _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_GD2, "GD2"); } /* }}} */ @@ -2859,7 +2859,7 @@ PHP_FUNCTION(imagegd2) Output BMP image to browser or file */ PHP_FUNCTION(imagebmp) { - _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_BMP, "BMP", gdImageBmpCtx); + _php_image_output_ctx(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_TYPE_BMP, "BMP"); } /* }}} */ #endif @@ -4146,7 +4146,7 @@ static void php_imagettftext_common(INTE Output WBMP image to browser or file */ PHP_FUNCTION(image2wbmp) { - _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_CONVERT_WBM, "WBMP", NULL); + _php_image_output(INTERNAL_FUNCTION_PARAM_PASSTHRU, PHP_GDIMG_CONVERT_WBM, "WBMP"); } /* }}} */ diff -up a/ext/gd/gd_ctx.c.proto b/ext/gd/gd_ctx.c --- a/ext/gd/gd_ctx.c.proto 2025-02-13 11:42:48.478248591 +0100 +++ b/ext/gd/gd_ctx.c 2025-02-13 11:52:48.325740296 +0100 @@ -77,7 +77,7 @@ static void _php_image_stream_ctxfreeand } /* }}} */ /* {{{ _php_image_output_ctx */ -static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn, void (*func_p)()) +static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type, char *tn) { zval *imgind; char *file = NULL; @@ -177,16 +177,20 @@ static void _php_image_output_ctx(INTERN switch(image_type) { case PHP_GDIMG_TYPE_JPG: - (*func_p)(im, ctx, q); + gdImageJpegCtx(im, ctx, q); break; case PHP_GDIMG_TYPE_WEBP: if (q == -1) { q = 80; } - (*func_p)(im, ctx, q); + gdImageWebpCtx(im, ctx, q); break; case PHP_GDIMG_TYPE_PNG: - (*func_p)(im, ctx, q, f); +#ifdef HAVE_GD_BUNDLED + gdImagePngCtxEx(im, ctx, q, f); +#else + gdImagePngCtxEx(im, ctx, q); +#endif break; case PHP_GDIMG_TYPE_XBM: case PHP_GDIMG_TYPE_WBM: @@ -197,16 +201,16 @@ static void _php_image_output_ctx(INTERN q = i; } if (image_type == PHP_GDIMG_TYPE_XBM) { - (*func_p)(im, file ? file : "", q, ctx); + gdImageXbmCtx(im, file ? file : "", q, ctx); } else { - (*func_p)(im, q, ctx); + gdImageWBMPCtx(im, q, ctx); } break; case PHP_GDIMG_TYPE_BMP: - (*func_p)(im, ctx, (int) compressed); + gdImageBmpCtx(im, ctx, (int) compressed); break; - default: - (*func_p)(im, ctx); + case PHP_GDIMG_TYPE_GIF: + gdImageGifCtx(im, ctx); break; } From b7356692f69f4ac0a07ea54e83debdd04b426dcb Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 14:41:11 +0100 Subject: [PATCH] Specify function pointer signature for scanf implementation Fix [-Wstrict-prototypes] warnings in standard/scanf.c --- 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 f58b4195cc599..78ecc1642cf92 100644 --- a/ext/standard/scanf.c +++ b/ext/standard/scanf.c @@ -108,6 +108,8 @@ typedef struct CharSet { } *ranges; } CharSet; +typedef zend_long (*int_string_formater)(const char*, char**, int); + /* * Declarations for functions used only in this file. */ @@ -585,7 +587,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 @@ -750,29 +752,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': From 2068d230d981d7b06b41b87ebc37ab2581b79852 Mon Sep 17 00:00:00 2001 From: George Peter Banyard Date: Wed, 12 May 2021 18:54:57 +0100 Subject: [PATCH] Fix [-Wstrict-prototypes] warning in PCNTL extension To achieve this we need to introduce a new wrapper function with dummy arguments which calls pcntl_signal_dispatch() to respect the function pointer signature for a tick function. --- 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..c116eff7d034a 100644 --- a/ext/pcntl/pcntl.c +++ b/ext/pcntl/pcntl.c @@ -252,7 +252,8 @@ static void pcntl_siginfo_to_zval(int, s #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) @@ -587,7 +588,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; @@ -1549,6 +1550,11 @@ void pcntl_signal_dispatch() sigprocmask(SIG_SETMASK, &old_mask, NULL); } +static void pcntl_signal_dispatch_tick_function(int dummy_int, void *dummy_pointer) +{ + return pcntl_signal_dispatch(); +} + /* {{{ proto bool pcntl_async_signals([bool on[) Enable/disable asynchronous signal handling and return the old setting. */ PHP_FUNCTION(pcntl_async_signals)