From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 71C98389366D; Thu, 28 Sep 2023 17:51:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 71C98389366D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695923518; bh=Am3/Jm2+YZ+Wro0FGD/S/jYy7uL29yu+1BkLiUnW+hs=; h=From:To:Subject:Date:From; b=gNyr75AX8BwfGcdCVsIE0CWrSk4pXs9wX8TEg6y+53rlGYi5RD9EIzJqr1sjPLtzh DsW+uZgYCaQYxSVeKs+p0q8RgKo1S90l5tmrigckSQnySNE7vBhT8rkRPZyNFiYaEr RFMh0WogjDwS1THDDnj3s/V9QroC01epcSz0rKtg= 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: dbb1d199a12e521544a36667b15193cb99a61d0c X-Git-Newrev: 07adefbb3198257a7e626a5c2db472f101b72b22 Message-Id: <20230928175158.71C98389366D@sourceware.org> Date: Thu, 28 Sep 2023 17:51:58 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=07adefbb3198257a7e626a5c2db472f101b72b22 commit 07adefbb3198257a7e626a5c2db472f101b72b22 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 6d6d96e800..3079ecb06b 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) {