[devel] Changes to remove gcc warnings (John Bowler)

Certain optional gcc warning flags resulted in warnings in libpng code.
With these changes only -Wconversion and -Wcast-qual cannot be turned on.
Changes are trivial rearrangements of code.  -Wconversion is not possible
for pngrutil.c (because of the widespread use of += et al on variables
smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
with pngwio.c and pngwutil.c because the 'write' callback and zlib
compression both fail to declare their input buffers with 'const'.
This commit is contained in:
Glenn Randers-Pehrson 2010-11-21 14:06:41 -06:00
parent 105c416007
commit b3edc73afa
8 changed files with 63 additions and 2 deletions

View File

@ -442,6 +442,15 @@ Version 1.5.0beta55 [November 21, 2010]
Fixed atomicity of chunk header serialization (Cosmin)
Added test for io_state in pngtest.c (Cosmin)
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
Changes to remove gcc warnings (John Bowler)
Certain optional gcc warning flags resulted in warnings in libpng code.
With these changes only -Wconversion and -Wcast-qual cannot be turned on.
Changes are trivial rearrangements of code. -Wconversion is not possible
for pngrutil.c (because of the widespread use of += et al on variables
smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
with pngwio.c and pngwutil.c because the 'write' callback and zlib
compression both fail to declare their input buffers with 'const'.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit

View File

@ -3080,6 +3080,15 @@ Version 1.5.0beta55 [November 21, 2010]
Fixed atomicity of chunk header serialization (Cosmin)
Added test for io_state in pngtest.c (Cosmin)
Added "#!/bin/sh" at the top of contrib/pngminim/*/gather.sh scripts.
Changes to remove gcc warnings (John Bowler)
Certain optional gcc warning flags resulted in warnings in libpng code.
With these changes only -Wconversion and -Wcast-qual cannot be turned on.
Changes are trivial rearrangements of code. -Wconversion is not possible
for pngrutil.c (because of the widespread use of += et al on variables
smaller than (int) or (unsigned int)) and -Wcast-qual is not possible
with pngwio.c and pngwutil.c because the 'write' callback and zlib
compression both fail to declare their input buffers with 'const'.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -1137,6 +1137,7 @@ png_push_process_row(png_structp png_ptr)
break;
}
default:
case 6:
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);

View File

@ -618,6 +618,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
}
break;
default:
case 6:
if (!(png_ptr->row_number & 1))
{

View File

@ -719,6 +719,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
case 3:
png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
break;
default:
png_error(png_ptr, "invalid error action to rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -886,6 +891,8 @@ png_init_read_transformations(png_structp png_ptr)
}
break;
default:
case 8:
case 16:
@ -1088,6 +1095,9 @@ png_init_read_transformations(png_structp png_ptr)
gs = png_reciprocal2(png_ptr->background_gamma,
png_ptr->screen_gamma);
break;
default:
png_error(png_ptr, "invalid background gamma type");
}
png_ptr->background_1.gray = png_gamma_correct(png_ptr,
@ -1725,6 +1735,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = (png_byte)(8 * row_info->channels);
@ -1785,6 +1798,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
switch (row_info->bit_depth)
{
default:
break;
case 2:
{
png_bytep bp;
@ -2966,6 +2982,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
break;
}
@ -3438,6 +3457,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
@ -3646,6 +3668,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
}
}
@ -3744,6 +3769,9 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;
row_info->pixel_depth = 8;
@ -3901,6 +3929,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;

View File

@ -98,6 +98,11 @@ png_get_int_32)(png_const_bytep buf)
png_uint_16 (PNGAPI
png_get_uint_16)(png_const_bytep buf)
{
/* ANSI-C requires an int value to accomodate at least 16 bits so this
* works and allows the compiler not to worry about possible narrowing
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
* than 16 bits either.)
*/
unsigned int val =
((unsigned int)(*buf) << 8) +
((unsigned int)(*(buf + 1)));

View File

@ -220,6 +220,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
break;
}
default:
break;
}
row_info->bit_depth = (png_byte)bit_depth;

View File

@ -257,10 +257,12 @@ png_text_compress(png_structp png_ptr,
*/
/* Set up the compression buffers */
/* TODO: the following cast hides a potential overflow problem. */
png_ptr->zstream.avail_in = (uInt)text_len;
/* NOTE: assume zlib doesn't overwrite the input */
png_ptr->zstream.next_in = (Bytef *)text;
png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
png_ptr->zstream.next_out = (Bytef *)png_ptr->zbuf;
png_ptr->zstream.avail_out = png_ptr->zbuf_size;
png_ptr->zstream.next_out = png_ptr->zbuf;
/* This is the same compression loop as in png_write_row() */
do