[libpng16] Removed one of the GCC-7.1.0 'strict-overflow' warnings that

result when integers appear on both sides of a compare.  Worked around the
  others by forcing the strict-overflow setting in the relevant functions to
  a level where they are not reported.
Changed "FALL THROUGH" comments to "FALLTHROUGH" because GCC doesn't like
  the space.
Worked around some C-style casts from (void*) because g++ 5.4.0 objects
  to them.
Increased the buffer size for 'sprint' to pass the gcc 7.1.0 'sprint
  overflow' check that is on by default with -Wall -Wextra.
This commit is contained in:
John Bowler
2017-07-11 07:50:35 -05:00
committed by Glenn Randers-Pehrson
parent ecea632c4c
commit 72d07d3202
13 changed files with 124 additions and 60 deletions

View File

@@ -1,9 +1,8 @@
/*-
* pngstest.c
*
* Copyright (c) 2013-2016 John Cunningham Bowler
*
* Last changed in libpng 1.6.24 [August 4, 2016]
* Last changed in libpng 1.6.31 [(PENDING RELEASE)]
* Copyright (c) 2013-2017 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -2746,22 +2745,27 @@ compare_two_images(Image *a, Image *b, int via_linear,
*/
else if ((a->opts & ACCUMULATE) == 0)
{
# ifdef __GNUC__
# define BYTE_CHARS 20 /* 2^32: GCC sprintf warning */
# else
# define BYTE_CHARS 3 /* 2^8: real maximum value */
# endif
/* Check the original image first,
* TODO: deal with input images with bad pixel values?
*/
if (amax >= a->image.colormap_entries)
{
char pindex[9];
sprintf(pindex, "%d[%lu]", amax,
(unsigned long)a->image.colormap_entries);
char pindex[3+2*BYTE_CHARS];
sprintf(pindex, "%d[%u]", amax,
(png_byte)/*SAFE*/a->image.colormap_entries);
return logerror(a, a->file_name, ": bad pixel index: ", pindex);
}
else if (bmax >= b->image.colormap_entries)
{
char pindex[9];
sprintf(pindex, "%d[%lu]", bmax,
(unsigned long)b->image.colormap_entries);
char pindex[3+2*BYTE_CHARS];
sprintf(pindex, "%d[%u]", bmax,
(png_byte)/*SAFE*/b->image.colormap_entries);
return logerror(b, b->file_name, ": bad pixel index: ", pindex);
}
}
@@ -2881,10 +2885,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
{
case 4:
if (pua[btoa[3]] != pub[3]) break;
/* FALLTHROUGH */
case 3:
if (pua[btoa[2]] != pub[2]) break;
/* FALLTHROUGH */
case 2:
if (pua[btoa[1]] != pub[1]) break;
/* FALLTHROUGH */
case 1:
if (pua[btoa[0]] != pub[0]) break;
if (alpha_added != 4 && pub[alpha_added] != 65535) break;
@@ -2900,10 +2907,13 @@ compare_two_images(Image *a, Image *b, int via_linear,
{
case 4:
if (psa[btoa[3]] != psb[3]) break;
/* FALLTHROUGH */
case 3:
if (psa[btoa[2]] != psb[2]) break;
/* FALLTHROUGH */
case 2:
if (psa[btoa[1]] != psb[1]) break;
/* FALLTHROUGH */
case 1:
if (psa[btoa[0]] != psb[0]) break;
if (alpha_added != 4 && psb[alpha_added] != 255) break;