1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
|
From f566cba0bb6bd53b1d44d5097e68201412b00f7a Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@php.net>
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 --git a/ext/gd/gd.c b/ext/gd/gd.c
index 166e82b4321c9..ebd3c6c9c3d01 100644
--- a/ext/gd/gd.c
+++ b/ext/gd/gd.c
@@ -142,16 +142,16 @@ 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(zend_string *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(zend_string *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 gdIOCtx *create_stream_context_from_zval(zval *to_zval);
static gdIOCtx *create_stream_context(php_stream *stream, int close_stream);
static gdIOCtx *create_output_context();
static int _php_image_type(char data[12]);
/* output streaming (formerly gd_ctx.c) */
-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);
/*********************************************************
*
@@ -1464,7 +1464,7 @@ static int _php_image_type (char data[12
/* }}} */
/* {{{ _php_image_create_from_string */
-gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr (*ioctx_func_p)())
+gdImagePtr _php_image_create_from_string(zend_string *data, char *tn, gdImagePtr (*ioctx_func_p)(gdIOCtxPtr))
{
gdImagePtr im;
gdIOCtx *io_ctx;
@@ -1569,7 +1569,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;
@@ -1613,7 +1613,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;
@@ -1637,7 +1637,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);
}
@@ -1655,7 +1655,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;
#ifdef HAVE_GD_XPM
case PHP_GDIMG_TYPE_XPM:
@@ -1738,7 +1738,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
@@ -1767,7 +1767,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);
}
/* }}} */
@@ -1790,7 +1790,7 @@ PHP_FUNCTION(imagecreatefromtga)
#endif
/* {{{ _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;
@@ -1837,13 +1837,13 @@ static void _php_image_output(INTERNAL_F
switch (image_type) {
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;
EMPTY_SWITCH_DEFAULT_CASE()
}
@@ -1863,13 +1863,13 @@ static void _php_image_output(INTERNAL_F
switch (image_type) {
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;
EMPTY_SWITCH_DEFAULT_CASE()
}
@@ -1939,7 +1939,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");
}
/* }}} */
@@ -1947,7 +1947,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 */
@@ -1956,7 +1956,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 */
@@ -1965,7 +1965,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 */
@@ -2017,14 +2017,14 @@ 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");
}
/* }}} */
/* {{{ 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");
}
/* }}} */
@@ -4154,7 +4154,7 @@ static gdIOCtx *create_output_context()
return 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;
zend_long quality = -1, basefilter = -1;
@@ -4189,13 +4189,13 @@ static void _php_image_output_ctx(INTERN
switch (image_type) {
case PHP_GDIMG_TYPE_JPG:
- (*func_p)(im, ctx, (int) quality);
+ gdImageJpegCtx(im, ctx, (int) quality);
break;
case PHP_GDIMG_TYPE_WEBP:
if (quality == -1) {
quality = 80;
}
- (*func_p)(im, ctx, (int) quality);
+ gdImageWebpCtx(im, ctx, (int) quality);
break;
#ifdef HAVE_GD_PNG
case PHP_GDIMG_TYPE_PNG:
@@ -4207,7 +4207,7 @@ static void _php_image_output_ctx(INTERN
break;
#endif
case PHP_GDIMG_TYPE_GIF:
- (*func_p)(im, ctx);
+ gdImageGifCtx(im, ctx);
break;
EMPTY_SWITCH_DEFAULT_CASE()
}
From b7356692f69f4ac0a07ea54e83debdd04b426dcb Mon Sep 17 00:00:00 2001
From: George Peter Banyard <girgias@php.net>
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
@@ -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)() = 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 (*)())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':
|