From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id B8DA63858C78; Wed, 17 Apr 2024 20:07:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8DA63858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713384436; bh=U21Xe4e+4M/eyekGdK6ljJh6db2hAW0FSZa2gMCfEI0=; h=From:To:Subject:Date:From; b=iD+Q7aJiuuRp65JHKZ2zq4MqOYnu1yxeCz4JjKZmC9U6q+nCGcOQvc5Khrtw0vwKm w22CylTCw0d9+sNBZcUQzsukHNRBNwvm6hPhdtuuF+VRLfYdY0bs30kH8pPSll0fCv q37VBBOWpKXthxKzQXxpd4Rbr+p5ZE9mOjfvtnHc= 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: d9559c575941030beb9774192a28f4117100c823 X-Git-Newrev: a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86 Message-Id: <20240417200716.B8DA63858C78@sourceware.org> Date: Wed, 17 Apr 2024 20:07:16 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86 commit a31deccd49a258d1fa4f415ede1ea0a1ea9ddc86 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) {