From cca3794dd0f51038c081874abf55b37236810ff4 Mon Sep 17 00:00:00 2001 From: Rangi Date: Mon, 6 Oct 2025 17:03:51 -0400 Subject: [PATCH] Mention libpng in its internal warning and error messages --- src/gfx/png.cpp | 16 ++++++++++------ src/gfx/reverse.cpp | 8 ++++---- test/gfx/damaged1.err | 2 +- test/gfx/damaged2.err | 2 +- test/gfx/damaged9.err | 2 +- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/gfx/png.cpp b/src/gfx/png.cpp index 8051fbd0..b9b8e815 100644 --- a/src/gfx/png.cpp +++ b/src/gfx/png.cpp @@ -31,15 +31,19 @@ struct Input { [[noreturn]] static void handleError(png_structp png, char const *msg) { - Input const &input = *reinterpret_cast(png_get_error_ptr(png)); - - fatal("Error reading PNG image (\"%s\"): %s", input.filename, msg); + fatal( + "libpng error while reading PNG image (\"%s\"): %s", + reinterpret_cast(png_get_error_ptr(png))->filename, + msg + ); } static void handleWarning(png_structp png, char const *msg) { - Input const &input = *reinterpret_cast(png_get_error_ptr(png)); - - warnx("In PNG image (\"%s\"): %s", input.filename, msg); + warnx( + "libpng found while reading PNG image (\"%s\"): %s", + reinterpret_cast(png_get_error_ptr(png))->filename, + msg + ); } static void readData(png_structp png, png_bytep data, size_t length) { diff --git a/src/gfx/reverse.cpp b/src/gfx/reverse.cpp index 21489eef..dffbb3cb 100644 --- a/src/gfx/reverse.cpp +++ b/src/gfx/reverse.cpp @@ -61,16 +61,16 @@ static std::vector readInto(std::string const &path) { [[noreturn]] static void pngError(png_structp png, char const *msg) { fatal( - "Error writing reversed image (\"%s\"): %s", - static_cast(png_get_error_ptr(png)), + "libpng error while writing reversed image (\"%s\"): %s", + reinterpret_cast(png_get_error_ptr(png)), msg ); } static void pngWarning(png_structp png, char const *msg) { warnx( - "While writing reversed image (\"%s\"): %s", - static_cast(png_get_error_ptr(png)), + "libpng found while writing reversed image (\"%s\"): %s", + reinterpret_cast(png_get_error_ptr(png)), msg ); } diff --git a/test/gfx/damaged1.err b/test/gfx/damaged1.err index 4cf84370..68b8e494 100644 --- a/test/gfx/damaged1.err +++ b/test/gfx/damaged1.err @@ -1,2 +1,2 @@ -FATAL: Error reading PNG image ("damaged1.png"): IDAT: invalid code -- missing end-of-block +FATAL: libpng error while reading PNG image ("damaged1.png"): IDAT: invalid code -- missing end-of-block Conversion aborted after 1 error diff --git a/test/gfx/damaged2.err b/test/gfx/damaged2.err index 5cfd98ad..78a5f7ca 100644 --- a/test/gfx/damaged2.err +++ b/test/gfx/damaged2.err @@ -1,2 +1,2 @@ -FATAL: Error reading PNG image ("damaged2.png"): IDAT: invalid code -- missing end-of-block +FATAL: libpng error while reading PNG image ("damaged2.png"): IDAT: invalid code -- missing end-of-block Conversion aborted after 1 error diff --git a/test/gfx/damaged9.err b/test/gfx/damaged9.err index 51ffde74..44c93f51 100644 --- a/test/gfx/damaged9.err +++ b/test/gfx/damaged9.err @@ -1,2 +1,2 @@ -FATAL: Error reading PNG image ("damaged9.png"): IDAT: invalid code -- missing end-of-block +FATAL: libpng error while reading PNG image ("damaged9.png"): IDAT: invalid code -- missing end-of-block Conversion aborted after 1 error