From 5525672a5fe0c0a51c2e1024fd011dba6eb2b7c1 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 7 Feb 2024 19:16:06 +0100 Subject: [PATCH] build: avoid "-Werror=format-extra-args" warnings in detecting printf for gnulib Otherwise, `CFLAGS='-Wall -Werror' meson build` fails detection with: Running compile: Working directory: /data/src/glib/build/meson-private/tmpoozk2y4b Code: #include #include static char buf[100]; static double zero = 0.0; int main () { if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 || (strcmp (buf, " inf") != 0 && strcmp (buf, " infinity") != 0)) return 1; return 0; } ----------- Command line: `cc /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c -o /data/src/glib/build/meson-private/tmpoozk2y4b/output.exe -Werror -Wall -D_FILE_OFFSET_BITS=64 -O0 -std=gnu99` -> 1 stderr: /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: In function 'main': /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c:8:21: error: too many arguments for format [-Werror=format-extra-args] 8 | if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 | ^~~~~~~ cc1: all warnings being treated as errors ----------- Could not compile test file /data/src/glib/build/meson-private/tmpoozk2y4b/testfile.c: 1 Checking if "printf supports the zero flag correctly" runs: DID NOT COMPILE --- glib/gnulib/gl_cv_func_printf_directive_f/meson.build | 2 +- glib/gnulib/gl_cv_func_printf_flag_zero/meson.build | 2 +- glib/gnulib/gl_cv_func_printf_long_double/meson.build | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/glib/gnulib/gl_cv_func_printf_directive_f/meson.build b/glib/gnulib/gl_cv_func_printf_directive_f/meson.build index afde78bf8..5137e98b1 100644 --- a/glib/gnulib/gl_cv_func_printf_directive_f/meson.build +++ b/glib/gnulib/gl_cv_func_printf_directive_f/meson.build @@ -15,7 +15,7 @@ static double zero = 0.0; int main () { int result = 0; - if (sprintf (buf, "%F %d", 1234567.0, 33, 44, 55) < 0 + if (sprintf (buf, "%F %d", 1234567.0, 33) < 0 || strcmp (buf, "1234567.000000 33") != 0) result |= 1; if (sprintf (buf, "%F", 1.0 / zero) < 0 diff --git a/glib/gnulib/gl_cv_func_printf_flag_zero/meson.build b/glib/gnulib/gl_cv_func_printf_flag_zero/meson.build index 2cb00a8e5..eea5dbb70 100644 --- a/glib/gnulib/gl_cv_func_printf_flag_zero/meson.build +++ b/glib/gnulib/gl_cv_func_printf_flag_zero/meson.build @@ -15,7 +15,7 @@ static char buf[100]; static double zero = 0.0; int main () { - if (sprintf (buf, "%010f", 1.0 / zero, 33, 44, 55) < 0 + if (sprintf (buf, "%010f", 1.0 / zero) < 0 || (strcmp (buf, " inf") != 0 && strcmp (buf, " infinity") != 0)) return 1; diff --git a/glib/gnulib/gl_cv_func_printf_long_double/meson.build b/glib/gnulib/gl_cv_func_printf_long_double/meson.build index 3d0e01934..2659ca39a 100644 --- a/glib/gnulib/gl_cv_func_printf_long_double/meson.build +++ b/glib/gnulib/gl_cv_func_printf_long_double/meson.build @@ -15,15 +15,15 @@ int main () { int result = 0; buf[0] = '\0'; - if (sprintf (buf, "%Lf %d", 1.75L, 33, 44, 55) < 0 + if (sprintf (buf, "%Lf %d", 1.75L, 33) < 0 || strcmp (buf, "1.750000 33") != 0) result |= 1; buf[0] = '\0'; - if (sprintf (buf, "%Le %d", 1.75L, 33, 44, 55) < 0 + if (sprintf (buf, "%Le %d", 1.75L, 33) < 0 || strcmp (buf, "1.750000e+00 33") != 0) result |= 2; buf[0] = '\0'; - if (sprintf (buf, "%Lg %d", 1.75L, 33, 44, 55) < 0 + if (sprintf (buf, "%Lg %d", 1.75L, 33) < 0 || strcmp (buf, "1.75 33") != 0) result |= 4; return result;