mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
contrib: Apply various fixes to libtests
pngimage.c: Initialize sig_bits on a NOTREACHED path to avoid warnings about using uninitialized variables. pngstest.c: Enlarge buffers and fix signedness to avoid legitimate warnings about potential buffer overflows. pngunknown.c: pngvalid.c: Use NULL instead of 0 for pointers and apply other style fixes. makepng.c: tarith.c: Apply various style fixes. Also remove the "last changed" version info from source comments. The version control system maintains this information automatically.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
|
||||
/* pngunknown.c - test the read side unknown chunk handling
|
||||
*
|
||||
* Last changed in libpng 1.6.32 [August 24, 2017]
|
||||
* Copyright (c) 2021 Cosmin Truta
|
||||
* Copyright (c) 2015,2017 Glenn Randers-Pehrson
|
||||
* Written by John Cunningham Bowler
|
||||
*
|
||||
@@ -370,7 +370,9 @@ find_by_flag(png_uint_32 flag)
|
||||
{
|
||||
int i = NINFO;
|
||||
|
||||
while (--i >= 0) if (chunk_info[i].flag == flag) return i;
|
||||
while (--i >= 0)
|
||||
if (chunk_info[i].flag == flag)
|
||||
return i;
|
||||
|
||||
fprintf(stderr, "pngunknown: internal error\n");
|
||||
exit(4);
|
||||
@@ -547,27 +549,30 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
|
||||
|
||||
case PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
case PNG_HANDLE_CHUNK_NEVER:
|
||||
discard = 1/*handled; discard*/;
|
||||
discard = 1; /*handled; discard*/
|
||||
break;
|
||||
|
||||
case PNG_HANDLE_CHUNK_IF_SAFE:
|
||||
case PNG_HANDLE_CHUNK_ALWAYS:
|
||||
discard = 0/*not handled; keep*/;
|
||||
discard = 0; /*not handled; keep*/
|
||||
break;
|
||||
}
|
||||
|
||||
/* Also store information about this chunk in the display, the relevant flag
|
||||
* is set if the chunk is to be kept ('not handled'.)
|
||||
*/
|
||||
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
|
||||
if (chunk >= 0)
|
||||
{
|
||||
png_uint_32 flag = chunk_info[chunk].flag;
|
||||
if (!discard) /* stupidity to stop a GCC warning */
|
||||
{
|
||||
png_uint_32 flag = chunk_info[chunk].flag;
|
||||
|
||||
if (pc->location & PNG_AFTER_IDAT)
|
||||
d->after_IDAT |= flag;
|
||||
if (pc->location & PNG_AFTER_IDAT)
|
||||
d->after_IDAT |= flag;
|
||||
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
else
|
||||
d->before_IDAT |= flag;
|
||||
}
|
||||
}
|
||||
|
||||
/* However if there is no support to store unknown chunks don't ask libpng to
|
||||
@@ -841,8 +846,9 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
|
||||
{
|
||||
png_uint_32 y;
|
||||
|
||||
for (y=0; y<height; ++y) if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
for (y=0; y<height; ++y)
|
||||
if (PNG_ROW_IN_INTERLACE_PASS(y, ipass))
|
||||
png_read_row(d->png_ptr, NULL, NULL);
|
||||
}
|
||||
}
|
||||
} /* interlaced */
|
||||
@@ -1091,15 +1097,15 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
|
||||
|
||||
static const char *standard_tests[] =
|
||||
{
|
||||
"discard", "default=discard", 0,
|
||||
"save", "default=save", 0,
|
||||
"if-safe", "default=if-safe", 0,
|
||||
"vpAg", "vpAg=if-safe", 0,
|
||||
"sTER", "sTER=if-safe", 0,
|
||||
"IDAT", "default=discard", "IDAT=save", 0,
|
||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||
"sBIT=save", "sRGB=save", "eXIf=save", 0,
|
||||
0/*end*/
|
||||
"discard", "default=discard", NULL,
|
||||
"save", "default=save", NULL,
|
||||
"if-safe", "default=if-safe", NULL,
|
||||
"vpAg", "vpAg=if-safe", NULL,
|
||||
"sTER", "sTER=if-safe", NULL,
|
||||
"IDAT", "default=discard", "IDAT=save", NULL,
|
||||
"sAPI", "bKGD=save", "cHRM=save", "gAMA=save", "all=discard", "iCCP=save",
|
||||
"sBIT=save", "sRGB=save", "eXIf=save", NULL,
|
||||
NULL /*end*/
|
||||
};
|
||||
|
||||
static PNG_NORETURN void
|
||||
@@ -1115,7 +1121,7 @@ int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
FILE *fp;
|
||||
png_uint_32 default_flags[4/*valid,unknown{before,after}*/];
|
||||
png_uint_32 default_flags[4]; /*valid,unknown{before,after}*/
|
||||
int strict = 0, default_tests = 0;
|
||||
const char *count_argv = "default=save";
|
||||
const char *touch_file = NULL;
|
||||
@@ -1153,8 +1159,9 @@ main(int argc, const char **argv)
|
||||
/* GCC BUG: if (default_tests && argc != 1) triggers some weird GCC argc
|
||||
* optimization which causes warnings with -Wstrict-overflow!
|
||||
*/
|
||||
else if (default_tests) if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
else if (default_tests)
|
||||
if (argc != 1)
|
||||
usage(d.program, "extra arguments");
|
||||
|
||||
/* The name of the test file is the last argument; remove it. */
|
||||
d.file = argv[--argc];
|
||||
@@ -1216,7 +1223,11 @@ main(int argc, const char **argv)
|
||||
const char *result;
|
||||
int arg_count = 0;
|
||||
|
||||
while (*next) ++next, ++arg_count;
|
||||
while (*next != NULL)
|
||||
{
|
||||
++next;
|
||||
++arg_count;
|
||||
}
|
||||
|
||||
perform_one_test_safe(fp, arg_count, test, default_flags, &d,
|
||||
this_test);
|
||||
|
||||
Reference in New Issue
Block a user