From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id B76823858419; Thu, 21 Dec 2023 18:53:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B76823858419 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1703184825; bh=Ez0oEbwSM8K8XxXGsjdMnOB8bRMHnmIDIAuTKp/URTo=; h=From:To:Subject:Date:From; b=MCsFqB/eCBr7gaxzmmzygQIcc1VwaoprWYBlv6QQRSCahxLLg5YTFfojNUvZqM4v1 rNABfMZs+g2EEleghi6ciuLDxozb6vsfLlDSR7HVUuVLavjfbDhqMCJC1poe3MrpN4 lZhhe7Mw+FQuyYY/5cKkjN5BrOuUd3HwSeJ5HGzM= 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: 60ce8011719ac64bd16892207d6fbc4bfabd67f7 X-Git-Newrev: bc65bf740f9de6e9ffa377c51b39b445456113a9 Message-Id: <20231221185345.B76823858419@sourceware.org> Date: Thu, 21 Dec 2023 18:53:45 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=bc65bf740f9de6e9ffa377c51b39b445456113a9 commit bc65bf740f9de6e9ffa377c51b39b445456113a9 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) {