]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
stdio: Fix -Wtautological-constant-out-of-range-compare on clang
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 17 Oct 2025 19:13:01 +0000 (16:13 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 21 Oct 2025 12:26:04 +0000 (09:26 -0300)
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.

Reviewed-by: Collin Funk <collin.funk1@gmail.com>
stdio-common/vfprintf-internal.c

index fa41e1b242fddf6d1a66d4db1ab73a7e5b4df810..2238137d6d532d992b02a0788fab8befeb47162b 100644 (file)
@@ -1337,7 +1337,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)
            {