[libpng16] Quieted 45 (out of 86 remaining) -Wconversion compiler warnings

This commit is contained in:
Glenn Randers-Pehrson 2016-10-02 17:08:46 -05:00
parent ad3318ddc8
commit 3875d9af4c
9 changed files with 91 additions and 80 deletions

View File

@ -41,15 +41,18 @@ Version 1.6.26beta01 [September 26, 2016]
Add tests/badcrc.png and tests/badadler.png to tests/pngtest. Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
Merged pngtest.c with libpng-1.7.0beta84/pngtest.c Merged pngtest.c with libpng-1.7.0beta84/pngtest.c
Version 1.6.26beta02 [September 30, 2016] Version 1.6.26beta02 [October 1, 2016]
Updated the documentation about CRC and ADLER32 handling. Updated the documentation about CRC and ADLER32 handling.
Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c, Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c,
pngwrite.c, pngunknown.c, and pngvalid.c. pngwrite.c, pngunknown.c, and pngvalid.c.
Quieted 116 (out of 288) -Wconversion compiler warnings by changing Quieted 58 (out of 144) -Wconversion compiler warnings by changing
flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes
in png.c, pngread.c, and pngwutil.c. in png.c, pngread.c, and pngwutil.c.
Version 1.6.26beta03 [October 2, 2016] Version 1.6.26beta03 [October 2, 2016]
Quieted 45 (out of 86 remaining) -Wconversion compiler warnings by
revising the png_isaligned() macro and trivial changes in png.c,
pngerror.c, pngget.c, pngset.c, and pngrutil.c.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -5719,15 +5719,18 @@ Version 1.6.26beta01 [September 26, 2016]
Add tests/badcrc.png and tests/badadler.png to tests/pngtest. Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
Merged pngtest.c with libpng-1.7.0beta84/pngtest.c Merged pngtest.c with libpng-1.7.0beta84/pngtest.c
Version 1.6.26beta02 [September 30, 2016] Version 1.6.26beta02 [October 1, 2016]
Updated the documentation about CRC and ADLER32 handling. Updated the documentation about CRC and ADLER32 handling.
Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c, Quieted 117 warnings from clang-3.8 in pngtrans.c, pngread.c,
pngwrite.c, pngunknown.c, and pngvalid.c. pngwrite.c, pngunknown.c, and pngvalid.c.
Quieted 116 (out of 288) -Wconversion compiler warnings by changing Quieted 58 (out of 144) -Wconversion compiler warnings by changing
flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes
in png.c, pngread.c, and pngwutil.c. in png.c, pngread.c, and pngwutil.c.
Version 1.6.26beta03 [October 2, 2016] Version 1.6.26beta03 [October 2, 2016]
Quieted 45 (out of 86 remaining) -Wconversion compiler warnings by
revising the png_isaligned() macro and trivial changes in png.c,
pngerror.c, pngget.c, pngset.c, and pngrutil.c.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

12
png.c
View File

@ -684,7 +684,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
void PNGAPI void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i) png_save_int_32(png_bytep buf, png_int_32 i)
{ {
png_save_uint_32(buf, i); png_save_uint_32(buf, (png_uint_32)i);
} }
# endif # endif
@ -2940,7 +2940,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
*/ */
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */ if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
{ {
czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */ czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */
exp_b10 = 0; /* Dot added below before first output. */ exp_b10 = 0; /* Dot added below before first output. */
} }
else else
@ -3118,11 +3118,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
if (exp_b10 < 0) if (exp_b10 < 0)
{ {
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */ *ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
uexp_b10 = -exp_b10; uexp_b10 = (unsigned int)(-exp_b10);
} }
else else
uexp_b10 = exp_b10; uexp_b10 = (unsigned int)exp_b10;
cdigits = 0; cdigits = 0;
@ -3184,9 +3184,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
/* Avoid overflow here on the minimum integer. */ /* Avoid overflow here on the minimum integer. */
if (fp < 0) if (fp < 0)
*ascii++ = 45, num = -fp; *ascii++ = 45, num = (png_uint_32)(-fp);
else else
num = fp; num = (png_uint_32)fp;
if (num <= 0x80000000) /* else overflowed */ if (num <= 0x80000000) /* else overflowed */
{ {

View File

@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* Last changed in libpng 1.6.24 [August 4, 2016] * Last changed in libpng 1.6.26 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
{ {
# define fixed_message "fixed point overflow in " # define fixed_message "fixed point overflow in "
# define fixed_message_ln ((sizeof fixed_message)-1) # define fixed_message_ln ((sizeof fixed_message)-1)
int iin; unsigned int iin;
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT]; char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
memcpy(msg, fixed_message, fixed_message_ln); memcpy(msg, fixed_message, fixed_message_ln);
iin = 0; iin = 0;

View File

@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* Last changed in libpng 1.6.24 [August 4, 2016] * Last changed in libpng 1.6.26 [(PENDING RELEASE)]
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm)
png_fixed_point result; png_fixed_point result;
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127, if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
5000) != 0) 5000) != 0)
return result; return (png_uint_32)result;
/* Overflow. */ /* Overflow. */
return 0; return 0;

View File

@ -1433,7 +1433,7 @@ png_image_read_header(png_voidp argument)
break; break;
case PNG_COLOR_TYPE_PALETTE: case PNG_COLOR_TYPE_PALETTE:
cmap_entries = png_ptr->num_palette; cmap_entries = (png_uint_32)png_ptr->num_palette;
break; break;
default: default:
@ -2251,7 +2251,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray[16] color-map: too few entries"); png_error(png_ptr, "gray[16] color-map: too few entries");
cmap_entries = make_gray_colormap(display); cmap_entries = (unsigned int)make_gray_colormap(display);
if (png_ptr->num_trans > 0) if (png_ptr->num_trans > 0)
{ {
@ -2349,7 +2349,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray+alpha color-map: too few entries"); png_error(png_ptr, "gray+alpha color-map: too few entries");
cmap_entries = make_ga_colormap(display); cmap_entries = (unsigned int)make_ga_colormap(display);
background_index = PNG_CMAP_GA_BACKGROUND; background_index = PNG_CMAP_GA_BACKGROUND;
output_processing = PNG_CMAP_GA; output_processing = PNG_CMAP_GA;
@ -2383,7 +2383,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray-alpha color-map: too few entries"); png_error(png_ptr, "gray-alpha color-map: too few entries");
cmap_entries = make_gray_colormap(display); cmap_entries = (unsigned int)make_gray_colormap(display);
if (output_encoding == P_LINEAR) if (output_encoding == P_LINEAR)
{ {
@ -2522,7 +2522,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "rgb[ga] color-map: too few entries"); png_error(png_ptr, "rgb[ga] color-map: too few entries");
cmap_entries = make_ga_colormap(display); cmap_entries = (unsigned int)make_ga_colormap(display);
background_index = PNG_CMAP_GA_BACKGROUND; background_index = PNG_CMAP_GA_BACKGROUND;
output_processing = PNG_CMAP_GA; output_processing = PNG_CMAP_GA;
} }
@ -2548,12 +2548,12 @@ png_image_read_colormap(png_voidp argument)
png_ptr->num_trans > 0) && png_ptr->num_trans > 0) &&
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0) png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
{ {
cmap_entries = make_gray_file_colormap(display); cmap_entries = (unsigned int)make_gray_file_colormap(display);
data_encoding = P_FILE; data_encoding = P_FILE;
} }
else else
cmap_entries = make_gray_colormap(display); cmap_entries = (unsigned int)make_gray_colormap(display);
/* But if the input has alpha or transparency it must be removed /* But if the input has alpha or transparency it must be removed
*/ */
@ -2641,7 +2641,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
png_error(png_ptr, "rgb+alpha color-map: too few entries"); png_error(png_ptr, "rgb+alpha color-map: too few entries");
cmap_entries = make_rgb_colormap(display); cmap_entries = (unsigned int)make_rgb_colormap(display);
/* Add a transparent entry. */ /* Add a transparent entry. */
png_create_colormap_entry(display, cmap_entries, 255, 255, png_create_colormap_entry(display, cmap_entries, 255, 255,
@ -2690,7 +2690,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries) if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
png_error(png_ptr, "rgb-alpha color-map: too few entries"); png_error(png_ptr, "rgb-alpha color-map: too few entries");
cmap_entries = make_rgb_colormap(display); cmap_entries = (unsigned int)make_rgb_colormap(display);
png_create_colormap_entry(display, cmap_entries, back_r, png_create_colormap_entry(display, cmap_entries, back_r,
back_g, back_b, 0/*unused*/, output_encoding); back_g, back_b, 0/*unused*/, output_encoding);
@ -2775,7 +2775,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "rgb color-map: too few entries"); png_error(png_ptr, "rgb color-map: too few entries");
cmap_entries = make_rgb_colormap(display); cmap_entries = (unsigned int)make_rgb_colormap(display);
output_processing = PNG_CMAP_RGB; output_processing = PNG_CMAP_RGB;
} }
} }
@ -2799,11 +2799,11 @@ png_image_read_colormap(png_voidp argument)
output_processing = PNG_CMAP_NONE; output_processing = PNG_CMAP_NONE;
data_encoding = P_FILE; /* Don't change from color-map indices */ data_encoding = P_FILE; /* Don't change from color-map indices */
cmap_entries = png_ptr->num_palette; cmap_entries = (unsigned int)png_ptr->num_palette;
if (cmap_entries > 256) if (cmap_entries > 256)
cmap_entries = 256; cmap_entries = 256;
if (cmap_entries > image->colormap_entries) if (cmap_entries > (unsigned int)image->colormap_entries)
png_error(png_ptr, "palette color-map: too few entries"); png_error(png_ptr, "palette color-map: too few entries");
for (i=0; i < cmap_entries; ++i) for (i=0; i < cmap_entries; ++i)

View File

@ -86,7 +86,7 @@ png_get_int_32)(png_const_bytep buf)
{ {
png_uint_32 uval = png_get_uint_32(buf); png_uint_32 uval = png_get_uint_32(buf);
if ((uval & 0x80000000) == 0) /* non-negative */ if ((uval & 0x80000000) == 0) /* non-negative */
return uval; return (png_int_32)uval;
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */ uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
if ((uval & 0x80000000) == 0) /* no overflow */ if ((uval & 0x80000000) == 0) /* no overflow */
@ -1014,7 +1014,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
#endif #endif
{ {
png_crc_finish(png_ptr, (int) length - num * 3); png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
} }
#ifndef PNG_READ_OPT_PLTE_SUPPORTED #ifndef PNG_READ_OPT_PLTE_SUPPORTED
@ -1720,13 +1720,13 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
data_length = length - (png_uint_32)(entry_start - buffer); data_length = length - (png_uint_32)(entry_start - buffer);
/* Integrity-check the data length */ /* Integrity-check the data length */
if ((data_length % entry_size) != 0) if ((data_length % (unsigned int)entry_size) != 0)
{ {
png_warning(png_ptr, "sPLT chunk has bad length"); png_warning(png_ptr, "sPLT chunk has bad length");
return; return;
} }
dl = (png_int_32)(data_length / entry_size); dl = (png_uint_32)(data_length / (unsigned int)entry_size);
max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry)); max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
if (dl > max_dl) if (dl > max_dl)
@ -1735,10 +1735,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
return; return;
} }
new_palette.nentries = (png_int_32)(data_length / entry_size); new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
new_palette.entries = (png_sPLT_entryp)png_malloc_warn( new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry))); (png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry)));
if (new_palette.entries == NULL) if (new_palette.entries == NULL)
{ {
@ -3102,7 +3102,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
# ifdef PNG_READ_PACKSWAP_SUPPORTED # ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((png_ptr->transformations & PNG_PACKSWAP) != 0) if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
/* little-endian byte */ /* little-endian byte */
end_mask = 0xff << end_mask; end_mask = (unsigned int)(0xff << end_mask);
else /* big-endian byte */ else /* big-endian byte */
# endif # endif
@ -3548,7 +3548,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{ {
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */ /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Offset to next interlace block */ /* Offset to next interlace block */
static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1}; static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
png_debug(1, "in png_do_read_interlace"); png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL) if (row != NULL && row_info != NULL)
@ -3563,9 +3563,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{ {
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3); png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3); png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
int sshift, dshift; unsigned int sshift, dshift;
int s_start, s_end, s_inc; unsigned int s_start, s_end;
int jstop = png_pass_inc[pass]; int s_inc;
int jstop = (int)png_pass_inc[pass];
png_byte v; png_byte v;
png_uint_32 i; png_uint_32 i;
int j; int j;
@ -3573,8 +3574,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
#ifdef PNG_READ_PACKSWAP_SUPPORTED #ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0) if ((transformations & PNG_PACKSWAP) != 0)
{ {
sshift = (int)((row_info->width + 7) & 0x07); sshift = ((row_info->width + 7) & 0x07);
dshift = (int)((final_width + 7) & 0x07); dshift = ((final_width + 7) & 0x07);
s_start = 7; s_start = 7;
s_end = 0; s_end = 0;
s_inc = -1; s_inc = -1;
@ -3583,8 +3584,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = 7 - (int)((row_info->width + 7) & 0x07); sshift = 7 - ((row_info->width + 7) & 0x07);
dshift = 7 - (int)((final_width + 7) & 0x07); dshift = 7 - ((final_width + 7) & 0x07);
s_start = 0; s_start = 0;
s_end = 7; s_end = 7;
s_inc = 1; s_inc = 1;
@ -3596,7 +3597,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
unsigned int tmp = *dp & (0x7f7f >> (7 - dshift)); unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
tmp |= v << dshift; tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff); *dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
@ -3606,7 +3607,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
dshift += s_inc; dshift = (unsigned int)((int)dshift + s_inc);
} }
if (sshift == s_end) if (sshift == s_end)
@ -3616,7 +3617,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
sshift += s_inc; sshift = (unsigned int)((int)sshift + s_inc);
} }
break; break;
} }
@ -3625,16 +3626,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{ {
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2); png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2); png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
int sshift, dshift; unsigned int sshift, dshift;
int s_start, s_end, s_inc; unsigned int s_start, s_end;
int jstop = png_pass_inc[pass]; int s_inc;
int jstop = (int)png_pass_inc[pass];
png_uint_32 i; png_uint_32 i;
#ifdef PNG_READ_PACKSWAP_SUPPORTED #ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0) if ((transformations & PNG_PACKSWAP) != 0)
{ {
sshift = (int)(((row_info->width + 3) & 0x03) << 1); sshift = (((row_info->width + 3) & 0x03) << 1);
dshift = (int)(((final_width + 3) & 0x03) << 1); dshift = (((final_width + 3) & 0x03) << 1);
s_start = 6; s_start = 6;
s_end = 0; s_end = 0;
s_inc = -2; s_inc = -2;
@ -3643,8 +3645,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1); sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1); dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
s_start = 0; s_start = 0;
s_end = 6; s_end = 6;
s_inc = 2; s_inc = 2;
@ -3659,7 +3661,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
unsigned int tmp = *dp & (0x3f3f >> (6 - dshift)); unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
tmp |= v << dshift; tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff); *dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
@ -3669,7 +3671,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
dshift += s_inc; dshift = (unsigned int)((int)dshift + s_inc);
} }
if (sshift == s_end) if (sshift == s_end)
@ -3679,7 +3681,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
sshift += s_inc; sshift = (unsigned int)((int)sshift + s_inc);
} }
break; break;
} }
@ -3688,16 +3690,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
{ {
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1); png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1); png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
int sshift, dshift; unsigned int sshift, dshift;
int s_start, s_end, s_inc; unsigned int s_start, s_end;
int s_inc;
png_uint_32 i; png_uint_32 i;
int jstop = png_pass_inc[pass]; int jstop = (int)png_pass_inc[pass];
#ifdef PNG_READ_PACKSWAP_SUPPORTED #ifdef PNG_READ_PACKSWAP_SUPPORTED
if ((transformations & PNG_PACKSWAP) != 0) if ((transformations & PNG_PACKSWAP) != 0)
{ {
sshift = (int)(((row_info->width + 1) & 0x01) << 2); sshift = (((row_info->width + 1) & 0x01) << 2);
dshift = (int)(((final_width + 1) & 0x01) << 2); dshift = (((final_width + 1) & 0x01) << 2);
s_start = 4; s_start = 4;
s_end = 0; s_end = 0;
s_inc = -4; s_inc = -4;
@ -3706,8 +3709,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
else else
#endif #endif
{ {
sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2); sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2); dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
s_start = 0; s_start = 0;
s_end = 4; s_end = 4;
s_inc = 4; s_inc = 4;
@ -3721,7 +3724,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
for (j = 0; j < jstop; j++) for (j = 0; j < jstop; j++)
{ {
unsigned int tmp = *dp & (0xf0f >> (4 - dshift)); unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
tmp |= v << dshift; tmp |= (unsigned int)(v << dshift);
*dp = (png_byte)(tmp & 0xff); *dp = (png_byte)(tmp & 0xff);
if (dshift == s_end) if (dshift == s_end)
@ -3731,7 +3734,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
dshift += s_inc; dshift = (unsigned int)((int)dshift + s_inc);
} }
if (sshift == s_end) if (sshift == s_end)
@ -3741,7 +3744,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
} }
else else
sshift += s_inc; sshift = (unsigned int)((int)sshift + s_inc);
} }
break; break;
} }
@ -3755,7 +3758,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes; png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
int jstop = png_pass_inc[pass]; int jstop = (int)png_pass_inc[pass];
png_uint_32 i; png_uint_32 i;
for (i = 0; i < row_info->width; i++) for (i = 0; i < row_info->width; i++)
@ -3899,7 +3902,7 @@ static void
png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row, png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row) png_const_bytep prev_row)
{ {
int bpp = (row_info->pixel_depth + 7) >> 3; unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
png_bytep rp_end = row + bpp; png_bytep rp_end = row + bpp;
/* Process the first pixel in the row completely (this is the same as 'up' /* Process the first pixel in the row completely (this is the same as 'up'
@ -3912,7 +3915,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
} }
/* Remainder */ /* Remainder */
rp_end += row_info->rowbytes - bpp; rp_end = rp_end + (row_info->rowbytes - bpp);
while (row < rp_end) while (row < rp_end)
{ {
@ -4265,7 +4268,7 @@ png_read_start_row(png_structrp png_ptr)
/* Offset to next interlace block in the y direction */ /* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2}; static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
int max_pixel_depth; unsigned int max_pixel_depth;
png_size_t row_bytes; png_size_t row_bytes;
png_debug(1, "in png_read_start_row"); png_debug(1, "in png_read_start_row");
@ -4294,7 +4297,7 @@ png_read_start_row(png_structrp png_ptr)
png_ptr->iwidth = png_ptr->width; png_ptr->iwidth = png_ptr->width;
} }
max_pixel_depth = png_ptr->pixel_depth; max_pixel_depth = (unsigned int)png_ptr->pixel_depth;
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of /* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
* calculations to calculate the final pixel depth, then * calculations to calculate the final pixel depth, then
@ -4429,7 +4432,7 @@ png_read_start_row(png_structrp png_ptr)
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0) if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
{ {
int user_pixel_depth = png_ptr->user_transform_depth * unsigned int user_pixel_depth = png_ptr->user_transform_depth *
png_ptr->user_transform_channels; png_ptr->user_transform_channels;
if (user_pixel_depth > max_pixel_depth) if (user_pixel_depth > max_pixel_depth)
@ -4451,7 +4454,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
* for safety's sake * for safety's sake
*/ */
row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) + row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
1 + ((max_pixel_depth + 7) >> 3); 1 + ((max_pixel_depth + 7) >> 3U);
#ifdef PNG_MAX_MALLOC_64K #ifdef PNG_MAX_MALLOC_64K
if (row_bytes > (png_uint_32)65536L) if (row_bytes > (png_uint_32)65536L)

View File

@ -343,7 +343,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
memcpy(info_ptr->pcal_units, units, length); memcpy(info_ptr->pcal_units, units, length);
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr, info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
(png_size_t)((nparams + 1) * (sizeof (png_charp))))); (png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
if (info_ptr->pcal_params == NULL) if (info_ptr->pcal_params == NULL)
{ {
@ -352,7 +352,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
return; return;
} }
memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp))); memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
(sizeof (png_charp)));
for (i = 0; i < nparams; i++) for (i = 0; i < nparams; i++)
{ {
@ -575,7 +576,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color)))); PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
if (num_palette > 0) if (num_palette > 0)
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color))); memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
(sizeof (png_color)));
info_ptr->palette = png_ptr->palette; info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette; info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@ -1092,7 +1094,7 @@ png_set_sPLT(png_const_structrp png_ptr,
* checked it when doing the allocation. * checked it when doing the allocation.
*/ */
memcpy(np->entries, entries->entries, memcpy(np->entries, entries->entries,
entries->nentries * sizeof (png_sPLT_entry)); (unsigned int)entries->nentries * sizeof (png_sPLT_entry));
/* Note that 'continue' skips the advance of the out pointer and out /* Note that 'continue' skips the advance of the out pointer and out
* count, so an invalid entry is not added. * count, so an invalid entry is not added.
@ -1261,7 +1263,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
{ {
png_app_error(png_ptr, "invalid unknown chunk location"); png_app_error(png_ptr, "invalid unknown chunk location");
/* Fake out the pre 1.6.0 behavior: */ /* Fake out the pre 1.6.0 behavior: */
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */ if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
location = PNG_AFTER_IDAT; location = PNG_AFTER_IDAT;
else else
@ -1385,7 +1387,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
return; return;
} }
num_chunks = num_chunks_in; num_chunks = (unsigned int)num_chunks_in;
} }
old_num_chunks = png_ptr->num_chunk_list; old_num_chunks = png_ptr->num_chunk_list;
@ -1575,7 +1577,7 @@ void PNGAPI
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask) png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
{ {
if (png_ptr != NULL && info_ptr != NULL) if (png_ptr != NULL && info_ptr != NULL)
info_ptr->valid &= ~mask; info_ptr->valid &= (unsigned int)(~mask);
} }

View File

@ -595,7 +595,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
return; /* The filler channel has gone already */ return; /* The filler channel has gone already */
/* Fix the rowbytes value. */ /* Fix the rowbytes value. */
row_info->rowbytes = dp-row; row_info->rowbytes = (unsigned int)(dp-row);
} }
#endif #endif