From b69768c8bd1a34fde311935c551d061ba52d9a3f Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 14 Apr 2024 08:08:00 +0100 Subject: [PATCH] xz: list: suppress -Wformat-nonliteral for Solaris Solaris' GCC can't understand that our use is fine, unlike modern compilers: ``` list.c: In function 'print_totals_basic': list.c:1191:4: error: format not a string literal, argument types not checked [-Werror=format-nonliteral] uint64_to_str(totals.files, 0)); ^~~~~~~~~~~~~ cc1: all warnings being treated as errors ``` It's presumably because of older gettext missing format attributes. This is with `gcc (GCC) 7.3.0`. --- src/xz/list.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/xz/list.c b/src/xz/list.c index ca9cf03e..10b8f7b0 100644 --- a/src/xz/list.c +++ b/src/xz/list.c @@ -1178,6 +1178,10 @@ print_totals_basic(void) totals.uncompressed_size), checks); +#if defined(__sun) && (defined(__GNUC__) || defined(__clang__)) +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wformat-nonliteral" +#endif // Since we print totals only when there are at least two files, // the English message will always use "%s files". But some other // languages need different forms for different plurals so we @@ -1189,6 +1193,9 @@ print_totals_basic(void) totals.files <= ULONG_MAX ? totals.files : (totals.files % 1000000) + 1000000), uint64_to_str(totals.files, 0)); +#if defined(__sun) && (defined(__GNUC__) || defined(__clang__)) +# pragma GCC diagnostic pop +#endif return; }