From f36a94207c1ed2eeeea7756882e7d738e6ff273e Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Fri, 13 Jun 2014 11:06:33 -0500 Subject: [PATCH] [libpng16] Quieted -Wsign-compare and -Wclobber compiler warnings in contrib/pngminus/*.c --- ANNOUNCE | 6 ++++-- CHANGES | 4 +++- contrib/pngminus/png2pnm.c | 27 +++++++++++++++++---------- contrib/pngminus/pnm2png.c | 35 ++++++++++++++++++++--------------- 4 files changed, 44 insertions(+), 28 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index f4b8ee005..6041d1529 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.13beta01 - June 12, 2014 +Libpng 1.6.13beta01 - June 13, 2014 This is not intended to be a public release. It will be replaced within a few weeks by a public version or by another test version. @@ -26,7 +26,9 @@ Other information: Changes since the last public release (1.6.13): -Version 1.6.13beta01 [June 12, 2014] +Version 1.6.13beta01 [June 13, 2014] + Quieted -Wsign-compare and -Wclobber compiler warnings in + contrib/pngminus/*.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 72cbeefe7..3d169d969 100644 --- a/CHANGES +++ b/CHANGES @@ -4940,7 +4940,9 @@ Version 1.6.12rc03 [June 8, 2014] Version 1.6.12 [June 12, 2014] No changes. -Version 1.6.13beta01 [June 12, 2014] +Version 1.6.13beta01 [June 13, 2014] + Quieted -Wsign-compare and -Wclobber compiler warnings in + contrib/pngminus/*.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/pngminus/png2pnm.c b/contrib/pngminus/png2pnm.c index aa9513ddc..83d9565a3 100644 --- a/contrib/pngminus/png2pnm.c +++ b/contrib/pngminus/png2pnm.c @@ -52,7 +52,8 @@ int main (int argc, char *argv[]); void usage (); -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha); +BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, + BOOL alpha); /* * main @@ -85,7 +86,8 @@ int main(int argc, char *argv[]) if ((fp_al = fopen (argv[argi], "wb")) == NULL) { fprintf (stderr, "PNM2PNG\n"); - fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]); + fprintf (stderr, "Error: can not create alpha-channel file %s\n", + argv[argi]); exit (1); } break; @@ -176,9 +178,11 @@ void usage() fprintf (stderr, "Usage: png2pnm [options] .png [.pnm]\n"); fprintf (stderr, " or: ... | png2pnm [options]\n"); fprintf (stderr, "Options:\n"); - fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); + fprintf (stderr, + " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n"); fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n"); - fprintf (stderr, " -a[lpha] .pgm write PNG alpha channel as pgm-file\n"); + fprintf (stderr, + " -a[lpha] .pgm write PNG alpha channel as pgm-file\n"); fprintf (stderr, " -h | -? print this help-information\n"); } @@ -186,7 +190,8 @@ void usage() * png2pnm */ -BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha) +BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, + volatile BOOL raw, BOOL alpha) { png_struct *png_ptr = NULL; png_info *info_ptr = NULL; @@ -315,12 +320,14 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a /* row_bytes is the width x number of channels x (bit-depth / 8) */ row_bytes = png_get_rowbytes (png_ptr, info_ptr); - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) { + if ((png_pixels = (png_byte *) + malloc (row_bytes * height * sizeof (png_byte))) == NULL) { png_destroy_read_struct (&png_ptr, &info_ptr, NULL); return FALSE; } - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) + if ((row_pointers = (png_byte **) + malloc (height * sizeof (png_bytep))) == NULL) { png_destroy_read_struct (&png_ptr, &info_ptr, NULL); free (png_pixels); @@ -329,7 +336,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a } /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) + for (i = 0; i < ((int) height); i++) row_pointers[i] = png_pixels + i * row_bytes; /* now we can go ahead and just read the whole image */ @@ -372,9 +379,9 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL a /* write data to PNM file */ pix_ptr = png_pixels; - for (row = 0; row < height; row++) + for (row = 0; row < (int) height; row++) { - for (col = 0; col < width; col++) + for (col = 0; col < (int) width; col++) { for (i = 0; i < (channels - alpha_present); i++) { diff --git a/contrib/pngminus/pnm2png.c b/contrib/pngminus/pnm2png.c index f9903dd32..b073414ff 100644 --- a/contrib/pngminus/pnm2png.c +++ b/contrib/pngminus/pnm2png.c @@ -50,7 +50,8 @@ int main (int argc, char *argv[]); void usage (); -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha); +BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, + BOOL alpha); void get_token(FILE *pnm_file, char *token); png_uint_32 get_data (FILE *pnm_file, int depth); png_uint_32 get_value (FILE *pnm_file, int depth); @@ -176,7 +177,8 @@ void usage() fprintf (stderr, " or: ... | pnm2png [options]\n"); fprintf (stderr, "Options:\n"); fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n"); - fprintf (stderr, " -a[lpha] .pgm read PNG alpha channel as pgm-file\n"); + fprintf (stderr, + " -a[lpha] .pgm read PNG alpha channel as pgm-file\n"); fprintf (stderr, " -h | -? print this help-information\n"); } @@ -184,27 +186,28 @@ void usage() * pnm2png */ -BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha) +BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, + BOOL alpha) { png_struct *png_ptr = NULL; png_info *info_ptr = NULL; png_byte *png_pixels = NULL; png_byte **row_pointers = NULL; png_byte *pix_ptr = NULL; - png_uint_32 row_bytes; + volatile png_uint_32 row_bytes; char type_token[16]; char width_token[16]; char height_token[16]; char maxval_token[16]; - int color_type; + volatile int color_type; unsigned long ul_width=0, ul_alpha_width=0; unsigned long ul_height=0, ul_alpha_height=0; unsigned long ul_maxval=0; - png_uint_32 width, alpha_width; - png_uint_32 height, alpha_height; + volatile png_uint_32 width, height; + volatile png_uint_32 alpha_width, alpha_height; png_uint_32 maxval; - int bit_depth = 0; + volatile int bit_depth = 0; int channels; int alpha_depth = 0; int alpha_present; @@ -367,23 +370,24 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, /* row_bytes is the width x number of channels x (bit-depth / 8) */ row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2); - if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) + if ((png_pixels = (png_byte *) + malloc (row_bytes * height * sizeof (png_byte))) == NULL) return FALSE; /* read data from PNM file */ pix_ptr = png_pixels; - for (row = 0; row < height; row++) + for (row = 0; row < (int) height; row++) { #if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) if (packed_bitmap) { - for (i = 0; i < row_bytes; i++) + for (i = 0; i < (int) row_bytes; i++) /* png supports this format natively so no conversion is needed */ *pix_ptr++ = get_data (pnm_file, 8); } else #endif { - for (col = 0; col < width; col++) + for (col = 0; col < (int) width; col++) { for (i = 0; i < (channels - alpha_present); i++) { @@ -462,7 +466,8 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, /* if needed we will allocate memory for an new array of row-pointers */ if (row_pointers == (unsigned char**) NULL) { - if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL) + if ((row_pointers = (png_byte **) + malloc (height * sizeof (png_bytep))) == NULL) { png_destroy_write_struct (&png_ptr, (png_infopp) NULL); return FALSE; @@ -470,13 +475,13 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, } /* set the individual row_pointers to point at the correct offsets */ - for (i = 0; i < (height); i++) + for (i = 0; i < (int) height; i++) row_pointers[i] = png_pixels + i * row_bytes; /* write out the entire image data in one call */ png_write_image (png_ptr, row_pointers); - /* write the additional chuncks to the PNG file (not really needed) */ + /* write the additional chunks to the PNG file (not really needed) */ png_write_end (png_ptr, info_ptr); /* clean up after the write, and free any memory allocated */