From 69a3e5bfd10e3d6d8b093dbfe8777002755496d4 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Fri, 25 Apr 2025 16:19:30 +0300 Subject: [PATCH] chore: Clean up the error directives Make the error directives uniformly consistent with one another. Remove surrounding quotes and trailing punctuation, and rephrase some of the error messages and some of their associated comments for either brevity or clarity. --- arm/arm_init.c | 8 ++++---- contrib/tools/pngfix.c | 4 ++-- mips/mips_init.c | 6 +++--- pngconf.h | 12 ++++++------ pngpriv.h | 18 ++++++++---------- pngtest.c | 4 ++-- powerpc/filter_vsx_intrinsics.c | 2 +- powerpc/powerpc_init.c | 2 +- 8 files changed, 27 insertions(+), 29 deletions(-) diff --git a/arm/arm_init.c b/arm/arm_init.c index 50376081a..0ea9c836c 100644 --- a/arm/arm_init.c +++ b/arm/arm_init.c @@ -35,14 +35,14 @@ #ifndef PNG_ARM_NEON_FILE # if defined(__aarch64__) || defined(_M_ARM64) /* ARM Neon is expected to be unconditionally available on ARM64. */ -# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64" +# error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64 # elif defined(__ARM_NEON__) || defined(__ARM_NEON) /* ARM Neon is expected to be available on the target CPU architecture. */ -# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch" +# error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch # elif defined(__linux__) # define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c" # else -# error "No support for run-time ARM Neon checking; use compile-time options" +# error No support for run-time ARM Neon checking; use compile-time options # endif #endif @@ -53,7 +53,7 @@ static int png_have_neon(png_structp png_ptr); #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */ #ifndef PNG_ALIGNED_MEMORY_SUPPORTED -# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +# error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED #endif void diff --git a/contrib/tools/pngfix.c b/contrib/tools/pngfix.c index 8d5dc46c2..3f0e334f8 100644 --- a/contrib/tools/pngfix.c +++ b/contrib/tools/pngfix.c @@ -32,7 +32,7 @@ #endif #if PNG_LIBPNG_VER < 10603 /* 1.6.3 */ -# error "pngfix will not work with libpng prior to 1.6.3" +# error pngfix requires libpng version 1.6.3 or newer #endif #ifdef PNG_SETJMP_SUPPORTED @@ -68,7 +68,7 @@ #endif #ifndef PNG_MAXIMUM_INFLATE_WINDOW -# error "pngfix not supported in this libpng version" +# error pngfix requires libpng with PNG_MAXIMUM_INFLATE_WINDOW supported #endif #if ZLIB_VERNUM >= 0x1240 diff --git a/mips/mips_init.c b/mips/mips_init.c index 143f0a371..5f9346f9e 100644 --- a/mips/mips_init.c +++ b/mips/mips_init.c @@ -48,7 +48,7 @@ static int png_have_msa(png_structp png_ptr); #include PNG_MIPS_MSA_FILE #else /* PNG_MIPS_MSA_FILE */ -# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks" +# error PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks #endif /* PNG_MIPS_MSA_FILE */ #endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */ @@ -66,12 +66,12 @@ static int png_have_mmi(); #include PNG_MIPS_MMI_FILE #else /* PNG_MIPS_MMI_FILE */ -# error "PNG_MIPS_MMI_FILE undefined: no support for run-time MIPS MMI checks" +# error PNG_MIPS_MMI_FILE undefined: no support for run-time MIPS MMI checks #endif /* PNG_MIPS_MMI_FILE */ #endif /* PNG_MIPS_MMI_CHECK_SUPPORTED*/ #ifndef PNG_ALIGNED_MEMORY_SUPPORTED -# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED" +# error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED #endif /* MIPS supports two optimizations: MMI and MSA. The appropriate diff --git a/pngconf.h b/pngconf.h index 314b6a3dd..9dcf99b05 100644 --- a/pngconf.h +++ b/pngconf.h @@ -219,7 +219,7 @@ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ # if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" +# error PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed # endif # define PNG_DLL_EXPORT __declspec(dllexport) @@ -467,7 +467,7 @@ #if CHAR_BIT == 8 && UCHAR_MAX == 255 typedef unsigned char png_byte; #else -# error "libpng requires 8-bit bytes" +# error libpng requires 8-bit bytes #endif #if INT_MIN == -32768 && INT_MAX == 32767 @@ -475,7 +475,7 @@ #elif SHRT_MIN == -32768 && SHRT_MAX == 32767 typedef short png_int_16; #else -# error "libpng requires a signed 16-bit type" +# error libpng requires a signed 16-bit integer type #endif #if UINT_MAX == 65535 @@ -483,7 +483,7 @@ #elif USHRT_MAX == 65535 typedef unsigned short png_uint_16; #else -# error "libpng requires an unsigned 16-bit type" +# error libpng requires an unsigned 16-bit integer type #endif #if INT_MIN < -2147483646 && INT_MAX > 2147483646 @@ -491,7 +491,7 @@ #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 typedef long int png_int_32; #else -# error "libpng requires a signed 32-bit (or more) type" +# error libpng requires a signed 32-bit (or longer) integer type #endif #if UINT_MAX > 4294967294U @@ -499,7 +499,7 @@ #elif ULONG_MAX > 4294967294U typedef unsigned long int png_uint_32; #else -# error "libpng requires an unsigned 32-bit (or more) type" +# error libpng requires an unsigned 32-bit (or longer) integer type #endif /* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t. diff --git a/pngpriv.h b/pngpriv.h index a86446108..a6f8d67d3 100644 --- a/pngpriv.h +++ b/pngpriv.h @@ -1000,17 +1000,15 @@ * must match that used in the build, or we must be using pnglibconf.h.prebuilt: */ #if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM -# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \ - "-I (include path) error: see the notes in pngpriv.h" - /* This means that when pnglibconf.h was built the copy of zlib.h that it - * used is not the same as the one being used here. Because the build of - * libpng makes decisions to use inflateInit2 and inflateReset2 based on the - * zlib version number and because this affects handling of certain broken - * PNG files the -I directives must match. +# error The include path of is incorrect + /* When pnglibconf.h was built, the copy of zlib.h that it used was not the + * same as the one being used here. Considering how libpng makes decisions + * to use the zlib API based on the zlib version number, the -I options must + * match. * - * The most likely explanation is that you passed a -I in CFLAGS. This will - * not work; all the preprocessor directives and in particular all the -I - * directives must be in CPPFLAGS. + * A possible cause of this mismatch is that you passed an -I option in + * CFLAGS, which is unlikely to work. All the preprocessor options, and all + * the -I options in particular, should be in CPPFLAGS. */ #endif diff --git a/pngtest.c b/pngtest.c index 94c91583f..73adaf98c 100644 --- a/pngtest.c +++ b/pngtest.c @@ -60,7 +60,7 @@ typedef png_libpng_version_1_6_48_git Your_png_h_is_not_version_1_6_48_git; PNG_LIBPNG_VER_MINOR) || \ (PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_SONUM) || \ (PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_DLLNUM) -# error "Inconsistent version numbers in png.h" +# error Inconsistent version numbers in "png.h" #endif /* In version 1.6.1, we added support for the configure test harness, which @@ -116,7 +116,7 @@ typedef png_libpng_version_1_6_48_git Your_png_h_is_not_version_1_6_48_git; # define pngtest_debug1(m, p1) ((void)0) # define pngtest_debug2(m, p1, p2) ((void)0) #else /* PNG_DEBUG < 0 */ -# error "Bad PNG_DEBUG value" +# error Bad PNG_DEBUG value #endif /* Turn on CPU timing diff --git a/powerpc/filter_vsx_intrinsics.c b/powerpc/filter_vsx_intrinsics.c index 01cf8800d..5acc17c94 100644 --- a/powerpc/filter_vsx_intrinsics.c +++ b/powerpc/filter_vsx_intrinsics.c @@ -23,7 +23,7 @@ #if PNG_POWERPC_VSX_OPT > 0 #ifndef __VSX__ -# error "This code requires VSX support (POWER7 and later). Please provide -mvsx compiler flag." +# error This code requires VSX support (POWER7 and later); please compile with -mvsx #endif #define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,data) diff --git a/powerpc/powerpc_init.c b/powerpc/powerpc_init.c index 902748009..70782eda1 100644 --- a/powerpc/powerpc_init.c +++ b/powerpc/powerpc_init.c @@ -46,7 +46,7 @@ static int png_have_vsx(png_structp png_ptr); #include PNG_POWERPC_VSX_FILE #else /* PNG_POWERPC_VSX_FILE */ -# error "PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks" +# error PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks #endif /* PNG_POWERPC_VSX_FILE */ #endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */