From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id B49FA3858C35; Fri, 9 Feb 2024 17:31:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B49FA3858C35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1707499898; bh=AQAQCgCp2lZyil/O040+nD012KHPr8Lsb8/5IzUZfZM=; h=From:To:Subject:Date:From; b=K9eURp3uXIm0kZVxbk1RX9Jf5Bv/d2pZn+Iv2LlwFV9aUJKsxZGSmqLdcbhekdvkK 5kj7PzCJ4Y5+UsuHUar066ZFPp2lqPCkag2D7Eku/tSy1tuOKM3K5s+9i/n8EGooUa NMbs/hYmGL/pnHPOhv989/7luk5hwFss3YqjBzww= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] stdio: Fix -Wtautological-constant-out-of-range-compare on clang X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 06bc3f31be54d8ced3cfadba2b0897b038af3fb7 X-Git-Newrev: 1812de79ab0b4e055773b2d4592e2b80b7a11f7b Message-Id: <20240209173138.B49FA3858C35@sourceware.org> Date: Fri, 9 Feb 2024 17:31:38 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=1812de79ab0b4e055773b2d4592e2b80b7a11f7b commit 1812de79ab0b4e055773b2d4592e2b80b7a11f7b Author: Adhemerval Zanella Date: Tue Jan 3 14:35:09 2023 -0300 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. Diff: --- stdio-common/vfprintf-internal.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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) {