about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-01-03 14:35:09 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2024-04-17 16:12:40 -0300
commita31deccd49a258d1fa4f415ede1ea0a1ea9ddc86 (patch)
treeb8576c146caf9ef6c534b861684f791a616939cf
parentd9559c575941030beb9774192a28f4117100c823 (diff)
downloadglibc-a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86.tar.gz
glibc-a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86.tar.xz
glibc-a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86.zip
stdio: Fix -Wtautological-constant-out-of-range-compare on clang
clang emits an error while building vfprintf-internal for default
case:

error: result of comparison of constant 255 with expression of type
'char' is always true
[-Werror,-Wtautological-constant-out-of-range-compare]
          if (spec <= UCHAR_MAX

The test is indeed not required for default non-wide build.
-rw-r--r--stdio-common/vfprintf-internal.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/stdio-common/vfprintf-internal.c b/stdio-common/vfprintf-internal.c
index 771beca9bf..ba5802cdb9 100644
--- a/stdio-common/vfprintf-internal.c
+++ b/stdio-common/vfprintf-internal.c
@@ -1338,7 +1338,12 @@ printf_positional (struct Xprintf_buffer * buf, const CHAR_T *format,
       /* Process format specifiers.  */
       do
 	{
-	  if (spec <= UCHAR_MAX
+# ifdef COMPILE_WPRINTF
+#  define CHECK_SPEC(spec) ((spec) <= UCHAR_MAX)
+# else
+#  define CHECK_SPEC(spec) (true)
+# endif
+	  if (CHECK_SPEC (spec)
 	      && __printf_function_table != NULL
 	      && __printf_function_table[(size_t) spec] != NULL)
 	    {