diff --git a/ANNOUNCE b/ANNOUNCE index aa3305b7a..02d5e938a 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.7.0beta48 - January 29, 2015 +Libpng 1.7.0beta48 - February 7, 2015 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. @@ -697,7 +697,9 @@ Version 1.7.0beta47 [January 29, 2015] Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and pngset.c to avoid warnings about dead code. -Version 1.7.0beta48 [January 29, 2015] +Version 1.7.0beta48 [February 7, 2015] + Work around one more Coverity-scan dead-code warning. + Do not build png_product2() when it is unused. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index ea37bea27..29acf169d 100644 --- a/CHANGES +++ b/CHANGES @@ -4986,7 +4986,9 @@ Version 1.7.0beta47 [January 29, 2015] Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and pngset.c to avoid warnings about dead code. -Version 1.7.0beta48 [January 29, 2015] +Version 1.7.0beta48 [February 7, 2015] + Work around one more Coverity-scan dead-code warning. + Do not build png_product2() when it is unused. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/png.c b/png.c index 8b2118314..ba00432f1 100644 --- a/png.c +++ b/png.c @@ -694,13 +694,13 @@ png_get_copyright(png_const_structrp png_ptr) #else # ifdef __STDC__ return PNG_STRING_NEWLINE \ - "libpng version 1.7.0beta48 - February 4, 2015" PNG_STRING_NEWLINE \ + "libpng version 1.7.0beta48 - February 7, 2015" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ PNG_STRING_NEWLINE; # else - return "libpng version 1.7.0beta48 - February 4, 2015\ + return "libpng version 1.7.0beta48 - February 7, 2015\ Copyright (c) 1998-2015 Glenn Randers-Pehrson\ Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; @@ -3319,34 +3319,28 @@ png_gamma_significant(png_fixed_point gamma_val) #endif #ifdef PNG_READ_GAMMA_SUPPORTED -#if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) +#ifdef PNG_16BIT_SUPPORTED +#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED /* A local convenience routine. */ static png_fixed_point png_product2(png_fixed_point a, png_fixed_point b) { /* The required result is 1/a * 1/b; the following preserves accuracy. */ -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED - double r = a * 1E-5; - r *= b; - r = floor(r+.5); - - if (r <= 2147483647. && r >= -2147483648.) - return (png_fixed_point)r; -#else png_fixed_point res; if (png_muldiv(&res, a, b, 100000) != 0) return res; -#endif return 0; /* overflow */ } -#endif /* 16BIT || !FLOATING_ARITHMETIC */ +#endif /* FLOATING_ARITHMETIC */ +#endif /* 16BIT */ /* The inverse of the above. */ png_fixed_point png_reciprocal2(png_fixed_point a, png_fixed_point b) { +#ifdef PNG_16BIT_SUPPORTED /* The required result is 1/a * 1/b; the following preserves accuracy. */ #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED if (a != 0 && b != 0) @@ -3357,18 +3351,19 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b) if (r <= 2147483647. && r >= -2147483648.) return (png_fixed_point)r; -#else - /* This may overflow because the range of png_fixed_point isn't - * symmetric, but this API is only used for the product of file and - * screen gamma so it doesn't matter that the smallest number it can - * produce is 1/21474, not 1/100000 - */ - png_fixed_point res = png_product2(a, b); - - if (res != 0) - return png_reciprocal(res); -#endif } +#else + /* This may overflow because the range of png_fixed_point isn't + * symmetric, but this API is only used for the product of file and + * screen gamma so it doesn't matter that the smallest number it can + * produce is 1/21474, not 1/100000 + */ + png_fixed_point res = png_product2(a, b); + + if (res != 0) + return png_reciprocal(res); +#endif +#endif /* 16BIT */ return 0; /* overflow */ } diff --git a/pngread.c b/pngread.c index 27e39d0db..1cb868e8b 100644 --- a/pngread.c +++ b/pngread.c @@ -2285,8 +2285,14 @@ png_image_read_colormap(png_voidp argument) output_processing = PNG_CMAP_NONE; break; } - +#ifdef __COVERITY__ + /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) + * here. + */ + back_alpha = 255; +#else back_alpha = output_encoding == P_LINEAR ? 65535 : 255; +#endif } /* output_processing means that the libpng-processed row will be @@ -2411,7 +2417,14 @@ png_image_read_colormap(png_voidp argument) */ background_index = i; png_create_colormap_entry(display, i++, back_r, back_g, back_b, - output_encoding == P_LINEAR ? 65535U : 255U, output_encoding); +#ifdef __COVERITY__ + /* Coverity claims that output_encoding cannot be 2 (P_LINEAR) + * here. + */ 255U, +#else + output_encoding == P_LINEAR ? 65535U : 255U, +#endif + output_encoding); /* For non-opaque input composite on the sRGB background - this * requires inverting the encoding for each component. The input diff --git a/pngrtran.c b/pngrtran.c index fb78ca43f..08c442e61 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -2991,18 +2991,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, w; - -#if 0 /* Coverity doesn't like this */ - red = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - green = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; - blue = (png_uint_16)(((*(sp))<<8) | *(sp + 1)); sp += 2; -#else png_byte hi,lo; hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); -#endif if (red == green && red == blue) { @@ -3047,10 +3040,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) for (i = 0; i < row_width; i++) { png_uint_16 red, green, blue, gray16; + png_byte hi,lo; - red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; - green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; - blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2; + hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo)); + hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo)); if (red != green || red != blue) rgb_error |= 1;