From 92ef313c772e69a7aa388f309a753c63b36f893d Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 27 Oct 2011 19:36:08 -0500 Subject: [PATCH] [libpng15] Fixed compiler warnings with Intel and MSYS compilers. The logical shift fix for Microsoft Visual C is required by other compilers, so this enables that fix for all compilers when using compile-time constants. Under MSYS 'byte' is a name declared in a system header file, so we changed the name of a local variable to avoid the warnings that result. --- ANNOUNCE | 9 +++++++-- CHANGES | 7 ++++++- pngrtran.c | 12 ++++++------ pngrutil.c | 16 ++++++++++------ 4 files changed, 29 insertions(+), 15 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index b4bfe67ff..7e7948786 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.6rc03 - October 27, 2011 +Libpng 1.5.6rc03 - October 28, 2011 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. @@ -96,8 +96,13 @@ Version 1.5.6rc02 [October 27, 2011] Added LSR() macro to defend against buggy compilers that evaluate non-taken code branches and complain about out-of-range shifts. -Version 1.5.6rc03 [October 27, 2011] +Version 1.5.6rc03 [October 28, 2011] Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. + Fixed compiler warnings with Intel and MSYS compilers. The logical shift + fix for Microsoft Visual C is required by other compilers, so this + enables that fix for all compilers when using compile-time constants. + Under MSYS 'byte' is a name declared in a system header file, so we + changed the name of a local variable to avoid the warnings that result. Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index 4b448f635..4d5aa2ce8 100644 --- a/CHANGES +++ b/CHANGES @@ -3657,8 +3657,13 @@ Version 1.5.6rc02 [October 27, 2011] Added LSR() macro to defend against buggy compilers that evaluate non-taken code branches and complain about out-of-range shifts. -Version 1.5.6rc03 [October 27, 2011] +Version 1.5.6rc03 [October 28, 2011] Renamed the LSR() macro to PNG_LSR() and added PNG_LSL() macro. + Fixed compiler warnings with Intel and MSYS compilers. The logical shift + fix for Microsoft Visual C is required by other compilers, so this + enables that fix for all compilers when using compile-time constants. + Under MSYS 'byte' is a name declared in a system header file, so we + changed the name of a local variable to avoid the warnings that result. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngrtran.c b/pngrtran.c index e87776ad9..fbf96690b 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -2484,8 +2484,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row, while (bp < bp_end) { - int byte = (*bp >> 1) & 0x55; - *bp++ = (png_byte)byte; + int b = (*bp >> 1) & 0x55; + *bp++ = (png_byte)b; } break; } @@ -2503,8 +2503,8 @@ png_do_unshift(png_row_infop row_info, png_bytep row, while (bp < bp_end) { - int byte = (*bp >> gray_shift) & mask; - *bp++ = (png_byte)byte; + int b = (*bp >> gray_shift) & mask; + *bp++ = (png_byte)b; } break; } @@ -2518,10 +2518,10 @@ png_do_unshift(png_row_infop row_info, png_bytep row, while (bp < bp_end) { - int byte = *bp >> shift[channel]; + int b = *bp >> shift[channel]; if (++channel >= channels) channel = 0; - *bp++ = (png_byte)byte; + *bp++ = (png_byte)b; } break; } diff --git a/pngrutil.c b/pngrutil.c index a7b584d67..059598546 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -2876,14 +2876,18 @@ png_combine_row(png_structp png_ptr, png_bytep dp, int display) * copied in the pass, 0 if not. 'S' is for the sparkle method, 'B' * for the block method. * - * With Microsoft Visual C and potentially other compilers the shifts - * below to extract the relevant fields from a 64 bit value are faulted - * if evaluated at compile time because the non-taken branch has an - * invalid shift (negative or more than 31), hence the following. + * With some compilers a compile time expression of the general form: * - * TO DO: Also identify the Intel C compiler here. + * (shift >= 32) ? (a >> (shift-32)) : (b >> shift) + * + * Produces warnings with values of 'shift' in the range 33 to 63 + * because the right hand side of the ?: expression is evalulated by + * the compiler even though it isn't used. Microsoft Visual C (various + * versions) and the Intel C compiler are known to do this. To avoid + * this the following macros are used in 1.5.6. This is a temporary + * solution to avoid destablizing the code during the release process. */ -# if defined PNG_USE_COMPILE_TIME_MASKS && defined _MSC_VER +# if PNG_USE_COMPILE_TIME_MASKS # define PNG_LSR(x,s) ((x)>>((s) & 0x1f)) # define PNG_LSL(x,s) ((x)<<((s) & 0x1f)) # else