Skip to content

Commit 345a75f

Browse files
committed
Remove dead code
`_php_image_output()` is only ever called for `PHP_GDIMG_CONVERT_WBM`, `PHP_GDIMG_TYPE_GD` and `PHP_GDIMG_TYPE_GD2`. All other image types solely use the more flexible `_php_image_output_ctx()`.
1 parent 7be0e06 commit 345a75f

File tree

2 files changed

+4
-35
lines changed

2 files changed

+4
-35
lines changed

ext/gd/gd.c

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2595,7 +2595,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
25952595
int q = -1, i, t = 1;
25962596

25972597
/* The quality parameter for Wbmp stands for the foreground when called from image2wbmp() */
2598-
/* When called from imagewbmp() the quality parameter stands for the foreground color. Default: black. */
25992598
/* The quality parameter for gd2 stands for chunk size */
26002599

26012600
if (zend_parse_parameters(argc, "r|pll", &imgind, &file, &file_len, &quality, &type) == FAILURE) {
@@ -2635,15 +2634,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
26352634
}
26362635
gdImageWBMP(im, q, fp);
26372636
break;
2638-
case PHP_GDIMG_TYPE_JPG:
2639-
(*func_p)(im, fp, q);
2640-
break;
2641-
case PHP_GDIMG_TYPE_WBM:
2642-
for (i = 0; i < gdImageColorsTotal(im); i++) {
2643-
if (gdImageRed(im, i) == 0) break;
2644-
}
2645-
(*func_p)(im, i, fp);
2646-
break;
26472637
case PHP_GDIMG_TYPE_GD:
26482638
(*func_p)(im, fp);
26492639
break;
@@ -2654,11 +2644,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
26542644
(*func_p)(im, fp, q, t);
26552645
break;
26562646
default:
2657-
if (q == -1) {
2658-
q = 128;
2659-
}
2660-
(*func_p)(im, fp, q, t);
2661-
break;
2647+
ZEND_ASSERT(0);
26622648
}
26632649
fflush(fp);
26642650
fclose(fp);
@@ -2684,17 +2670,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
26842670
}
26852671
gdImageWBMP(im, q, tmp);
26862672
break;
2687-
case PHP_GDIMG_TYPE_JPG:
2688-
(*func_p)(im, tmp, q);
2689-
break;
2690-
case PHP_GDIMG_TYPE_WBM:
2691-
for (i = 0; i < gdImageColorsTotal(im); i++) {
2692-
if (gdImageRed(im, i) == 0) {
2693-
break;
2694-
}
2695-
}
2696-
(*func_p)(im, q, tmp);
2697-
break;
26982673
case PHP_GDIMG_TYPE_GD:
26992674
(*func_p)(im, tmp);
27002675
break;
@@ -2705,8 +2680,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, char
27052680
(*func_p)(im, tmp, q, t);
27062681
break;
27072682
default:
2708-
(*func_p)(im, tmp);
2709-
break;
2683+
ZEND_ASSERT(0);
27102684
}
27112685

27122686
fseek(tmp, 0, SEEK_SET);

ext/gd/gd_ctx.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,8 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
9393
php_stream *stream;
9494
int close_stream = 1;
9595

96-
/* The third (quality) parameter for Wbmp stands for the foreground when called from image2wbmp().
97-
* The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called
98-
* from imagey<type>().
96+
/* The third (quality) parameter for Wbmp and Xbm stands for the foreground color index when called
97+
* from image<type>().
9998
*/
10099
switch (image_type) {
101100
case PHP_GDIMG_TYPE_XBM:
@@ -177,10 +176,6 @@ static void _php_image_output_ctx(INTERNAL_FUNCTION_PARAMETERS, int image_type,
177176
}
178177

179178
switch(image_type) {
180-
case PHP_GDIMG_CONVERT_WBM:
181-
if(q<0||q>255) {
182-
php_error_docref(NULL, E_WARNING, "Invalid threshold value '%d'. It must be between 0 and 255", q);
183-
}
184179
case PHP_GDIMG_TYPE_JPG:
185180
(*func_p)(im, ctx, q);
186181
break;

0 commit comments

Comments
 (0)