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

This commit is contained in:
Glenn Randers-Pehrson 2010-11-21 14:02:16 -06:00
parent c03a949a0d
commit 2922c07e67
8 changed files with 70 additions and 4 deletions

View File

@ -61,6 +61,14 @@ version 1.4.5beta06 [November 21, 2010]
is not defined).
Make the "png_get_uint_16" macro return a png_uint_32 in libpng-1.4 for API
compatibility.
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 glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -2713,6 +2713,14 @@ version 1.4.5beta06 [November 21, 2010]
is not defined).
Make the "png_get_uint_16" macro return a png_uint_32 in libpng-1.4 for API
compatibility.
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 glennrp at users.sourceforge.net
or to png-mng-implement at lists.sf.net (subscription required; visit

View File

@ -1109,6 +1109,8 @@ 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

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.4.5 [November 20, 2010]
* Last changed in libpng 1.4.5 [November 21, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -502,6 +502,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 1:
if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
{
@ -512,6 +513,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 2:
if ((png_ptr->row_number & 0x07) != 4)
{
@ -522,6 +524,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 3:
if ((png_ptr->row_number & 3) || png_ptr->width < 3)
{
@ -532,6 +535,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 4:
if ((png_ptr->row_number & 3) != 2)
{
@ -542,6 +546,7 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
case 5:
if ((png_ptr->row_number & 1) || png_ptr->width < 2)
{
@ -552,6 +557,8 @@ png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
return;
}
break;
default:
case 6:
if (!(png_ptr->row_number & 1))
{

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.4.5 [November 20, 2010]
* Last changed in libpng 1.4.5 [November 21, 2010]
* Copyright (c) 1998-2010 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -686,6 +686,11 @@ png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
break;
case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
break;
default:
png_error(png_ptr, "invalid error action in png_set_rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#ifdef PNG_READ_EXPAND_SUPPORTED
@ -828,6 +833,8 @@ png_init_read_transformations(png_structp png_ptr)
}
break;
default:
case 8:
case 16:
@ -1028,6 +1035,9 @@ png_init_read_transformations(png_structp png_ptr)
gs = 1.0 / (png_ptr->background_gamma *
png_ptr->screen_gamma);
break;
default:
png_error(png_ptr, "invalid background gamma type");
}
png_ptr->background_1.gray = (png_uint_16)(pow(
@ -1626,6 +1636,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);
@ -1682,6 +1695,9 @@ png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
switch (row_info->bit_depth)
{
default:
break;
case 2:
{
png_bytep bp;
@ -2798,6 +2814,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
break;
}
@ -3230,6 +3249,9 @@ png_do_background(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
@ -3428,6 +3450,9 @@ png_do_gamma(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
}
}
@ -3522,6 +3547,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;
@ -3672,6 +3700,9 @@ png_do_expand(png_row_infop row_info, png_bytep row,
}
break;
}
default:
break;
}
row_info->bit_depth = 8;

View File

@ -68,6 +68,11 @@ png_get_int_32)(png_bytep buf)
png_uint_16 (PNGAPI
png_get_uint_16) (png_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

@ -195,6 +195,9 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
*dp = (png_byte)v;
break;
}
default:
break;
}
row_info->bit_depth = (png_byte)bit_depth;
row_info->pixel_depth = (png_byte)(bit_depth * row_info->channels);

View File

@ -246,10 +246,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