@@ -1753,7 +1753,6 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, cons
1753
1753
char * file = NULL ;
1754
1754
zend_long quality = 128 , type = 1 ;
1755
1755
gdImagePtr im ;
1756
- FILE * fp ;
1757
1756
size_t file_len = 0 ;
1758
1757
1759
1758
/* The quality parameter for gd2 stands for chunk size */
@@ -1783,7 +1782,7 @@ static void _php_image_output(INTERNAL_FUNCTION_PARAMETERS, int image_type, cons
1783
1782
if (file_len ) {
1784
1783
PHP_GD_CHECK_OPEN_BASEDIR (file , "Invalid filename" );
1785
1784
1786
- fp = VCWD_FOPEN (file , "wb" );
1785
+ FILE * fp = VCWD_FOPEN (file , "wb" );
1787
1786
if (!fp ) {
1788
1787
php_error_docref (NULL , E_WARNING , "Unable to open \"%s\" for writing" , file );
1789
1788
RETURN_FALSE ;
@@ -1851,9 +1850,7 @@ PHP_FUNCTION(imagexbm)
1851
1850
zend_long foreground_color ;
1852
1851
bool foreground_color_is_null = true;
1853
1852
gdImagePtr im ;
1854
- int i ;
1855
1853
gdIOCtx * ctx = NULL ;
1856
- php_stream * stream ;
1857
1854
1858
1855
ZEND_PARSE_PARAMETERS_START (2 , 3 )
1859
1856
Z_PARAM_OBJECT_OF_CLASS (imgind , gd_image_ce )
@@ -1865,7 +1862,7 @@ PHP_FUNCTION(imagexbm)
1865
1862
im = php_gd_libgdimageptr_from_zval_p (imgind );
1866
1863
1867
1864
if (file != NULL ) {
1868
- stream = php_stream_open_wrapper (file , "wb" , REPORT_ERRORS |IGNORE_PATH , NULL );
1865
+ php_stream * stream = php_stream_open_wrapper (file , "wb" , REPORT_ERRORS |IGNORE_PATH , NULL );
1869
1866
if (stream == NULL ) {
1870
1867
RETURN_FALSE ;
1871
1868
}
@@ -1876,6 +1873,7 @@ PHP_FUNCTION(imagexbm)
1876
1873
}
1877
1874
1878
1875
if (foreground_color_is_null ) {
1876
+ int i ;
1879
1877
for (i = 0 ; i < gdImageColorsTotal (im ); i ++ ) {
1880
1878
if (!gdImageRed (im , i ) && !gdImageGreen (im , i ) && !gdImageBlue (im , i )) {
1881
1879
break ;
@@ -2083,7 +2081,6 @@ PHP_FUNCTION(imagewbmp)
2083
2081
zend_long foreground_color ;
2084
2082
bool foreground_color_is_null = true;
2085
2083
gdImagePtr im ;
2086
- int i ;
2087
2084
gdIOCtx * ctx ;
2088
2085
zval * to_zval = NULL ;
2089
2086
@@ -2102,6 +2099,7 @@ PHP_FUNCTION(imagewbmp)
2102
2099
}
2103
2100
2104
2101
if (foreground_color_is_null ) {
2102
+ int i ;
2105
2103
for (i = 0 ; i < gdImageColorsTotal (im ); i ++ ) {
2106
2104
if (!gdImageRed (im , i ) && !gdImageGreen (im , i ) && !gdImageBlue (im , i )) {
2107
2105
break ;
@@ -2462,7 +2460,6 @@ PHP_FUNCTION(imagegammacorrect)
2462
2460
{
2463
2461
zval * IM ;
2464
2462
gdImagePtr im ;
2465
- int i ;
2466
2463
double input , output , gamma ;
2467
2464
2468
2465
ZEND_PARSE_PARAMETERS_START (3 , 3 )
@@ -2486,11 +2483,9 @@ PHP_FUNCTION(imagegammacorrect)
2486
2483
im = php_gd_libgdimageptr_from_zval_p (IM );
2487
2484
2488
2485
if (gdImageTrueColor (im )) {
2489
- int x , y , c ;
2490
-
2491
- for (y = 0 ; y < gdImageSY (im ); y ++ ) {
2492
- for (x = 0 ; x < gdImageSX (im ); x ++ ) {
2493
- c = gdImageGetPixel (im , x , y );
2486
+ for (int y = 0 ; y < gdImageSY (im ); y ++ ) {
2487
+ for (int x = 0 ; x < gdImageSX (im ); x ++ ) {
2488
+ int c = gdImageGetPixel (im , x , y );
2494
2489
gdImageSetPixel (im , x , y ,
2495
2490
gdTrueColorAlpha (
2496
2491
(int ) ((pow ((gdTrueColorGetRed (c ) / 255.0 ), gamma ) * 255 ) + .5 ),
@@ -2504,7 +2499,7 @@ PHP_FUNCTION(imagegammacorrect)
2504
2499
RETURN_TRUE ;
2505
2500
}
2506
2501
2507
- for (i = 0 ; i < gdImageColorsTotal (im ); i ++ ) {
2502
+ for (int i = 0 ; i < gdImageColorsTotal (im ); i ++ ) {
2508
2503
im -> red [i ] = (int )((pow ((im -> red [i ] / 255.0 ), gamma ) * 255 ) + .5 );
2509
2504
im -> green [i ] = (int )((pow ((im -> green [i ] / 255.0 ), gamma ) * 255 ) + .5 );
2510
2505
im -> blue [i ] = (int )((pow ((im -> blue [i ] / 255.0 ), gamma ) * 255 ) + .5 );
@@ -2810,7 +2805,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
2810
2805
zval * var = NULL ;
2811
2806
gdImagePtr im ;
2812
2807
gdPointPtr points ;
2813
- int npoints , col , nelem , i ;
2808
+ int npoints , col , nelem ;
2814
2809
2815
2810
ZEND_PARSE_PARAMETERS_START (3 , 4 )
2816
2811
Z_PARAM_OBJECT_OF_CLASS (IM , gd_image_ce )
@@ -2850,7 +2845,7 @@ static void php_imagepolygon(INTERNAL_FUNCTION_PARAMETERS, int filled)
2850
2845
2851
2846
points = (gdPointPtr ) safe_emalloc (npoints , sizeof (gdPoint ), 0 );
2852
2847
2853
- for (i = 0 ; i < npoints ; i ++ ) {
2848
+ for (int i = 0 ; i < npoints ; i ++ ) {
2854
2849
if ((var = zend_hash_index_find (Z_ARRVAL_P (POINTS ), (i * 2 ))) != NULL ) {
2855
2850
points [i ].x = zval_get_long (var );
2856
2851
}
@@ -3712,7 +3707,7 @@ PHP_FUNCTION(imageconvolution)
3712
3707
zval * var = NULL , * var2 = NULL ;
3713
3708
gdImagePtr im_src = NULL ;
3714
3709
double div , offset ;
3715
- int i , j , res ;
3710
+ int res ;
3716
3711
float matrix [3 ][3 ] = {{0 ,0 ,0 }, {0 ,0 ,0 }, {0 ,0 ,0 }};
3717
3712
3718
3713
ZEND_PARSE_PARAMETERS_START (4 , 4 )
@@ -3729,14 +3724,14 @@ PHP_FUNCTION(imageconvolution)
3729
3724
RETURN_THROWS ();
3730
3725
}
3731
3726
3732
- for (i = 0 ; i < 3 ; i ++ ) {
3727
+ for (uint8_t i = 0 ; i < 3 ; i ++ ) {
3733
3728
if ((var = zend_hash_index_find_deref (Z_ARRVAL_P (hash_matrix ), (i ))) != NULL && Z_TYPE_P (var ) == IS_ARRAY ) {
3734
3729
if (zend_hash_num_elements (Z_ARRVAL_P (var )) != 3 ) {
3735
3730
zend_argument_value_error (2 , "must be a 3x3 array, matrix[%d] only has %d elements" , i , zend_hash_num_elements (Z_ARRVAL_P (var )));
3736
3731
RETURN_THROWS ();
3737
3732
}
3738
3733
3739
- for (j = 0 ; j < 3 ; j ++ ) {
3734
+ for (uint8_t j = 0 ; j < 3 ; j ++ ) {
3740
3735
if ((var2 = zend_hash_index_find (Z_ARRVAL_P (var ), j )) != NULL ) {
3741
3736
matrix [i ][j ] = (float ) zval_get_double (var2 );
3742
3737
} else {
@@ -4042,9 +4037,7 @@ PHP_FUNCTION(imageaffine)
4042
4037
gdRectPtr pRect = NULL ;
4043
4038
zval * z_rect = NULL ;
4044
4039
zval * z_affine ;
4045
- zval * tmp ;
4046
4040
double affine [6 ];
4047
- zval * zval_affine_elem = NULL ;
4048
4041
4049
4042
ZEND_PARSE_PARAMETERS_START (2 , 3 )
4050
4043
Z_PARAM_OBJECT_OF_CLASS (IM , gd_image_ce )
@@ -4062,7 +4055,8 @@ PHP_FUNCTION(imageaffine)
4062
4055
}
4063
4056
4064
4057
for (uint32_t i = 0 ; i < nelems ; i ++ ) {
4065
- if ((zval_affine_elem = zend_hash_index_find_deref (Z_ARRVAL_P (z_affine ), i )) != NULL ) {
4058
+ zval * zval_affine_elem = zend_hash_index_find_deref (Z_ARRVAL_P (z_affine ), i );
4059
+ if (zval_affine_elem != NULL ) {
4066
4060
switch (Z_TYPE_P (zval_affine_elem )) {
4067
4061
case IS_LONG :
4068
4062
case IS_DOUBLE :
@@ -4081,6 +4075,7 @@ PHP_FUNCTION(imageaffine)
4081
4075
}
4082
4076
4083
4077
if (z_rect != NULL ) {
4078
+ zval * tmp ;
4084
4079
if ((tmp = zend_hash_str_find (Z_ARRVAL_P (z_rect ), "x" , sizeof ("x" ) - 1 )) != NULL ) {
4085
4080
rect .x = zval_get_long (tmp );
4086
4081
} else {
@@ -4130,7 +4125,7 @@ PHP_FUNCTION(imageaffinematrixget)
4130
4125
zend_long type ;
4131
4126
zval * options = NULL ;
4132
4127
zval * tmp ;
4133
- int res = GD_FALSE , i ;
4128
+ int res = GD_FALSE ;
4134
4129
4135
4130
ZEND_PARSE_PARAMETERS_START (2 , 2 )
4136
4131
Z_PARAM_LONG (type )
@@ -4194,7 +4189,7 @@ PHP_FUNCTION(imageaffinematrixget)
4194
4189
RETURN_FALSE ;
4195
4190
} else {
4196
4191
array_init (return_value );
4197
- for (i = 0 ; i < 6 ; i ++ ) {
4192
+ for (uint8_t i = 0 ; i < 6 ; i ++ ) {
4198
4193
add_index_double (return_value , i , affine [i ]);
4199
4194
}
4200
4195
}
0 commit comments