[lipng17] Do not build png_product2() when it is unused and work around

one more Coverity-scan dead-code warning.
This commit is contained in:
Glenn Randers-Pehrson
2015-02-07 08:54:07 -06:00
parent d7312be749
commit 6ce2d220b4
5 changed files with 45 additions and 39 deletions

43
png.c
View File

@@ -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 */
}