From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Arnd Bergmann <arnd@kernel.org>,
Dave Kleikamp <shaggy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Zheng Yu <zheng.yu@northwestern.edu>
Cc: Arnd Bergmann <arnd@arndb.de>,
Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
Bill Wendling <morbo@google.com>,
Justin Stitt <justinstitt@google.com>,
Aditya Dutt <duttaditya18@gmail.com>,
Roman Smirnov <r.smirnov@omp.ru>,
jfs-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning
Date: Mon, 2 Feb 2026 11:34:34 -0600 [thread overview]
Message-ID: <fd1854c2-d3f1-4901-8b7d-c6ce944caf61@oracle.com> (raw)
In-Reply-To: <20260202094958.1232478-1-arnd@kernel.org>
On 2/2/26 3:49AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> A recent change for the range check started triggering a clang warning:
>
> fs/jfs/jfs_dtree.c:2906:31: error: result of comparison of constant 128 with expression of type 's8' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> 2906 | if (stbl[i] < 0 || stbl[i] >= DTPAGEMAXSLOT) {
> | ~~~~~~~ ^ ~~~~~~~~~~~~~
> fs/jfs/jfs_dtree.c:3111:30: error: result of comparison of constant 128 with expression of type 's8' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
> 3111 | if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
> | ~~~~~~~ ^ ~~~~~~~~~~~~~
>
> Both the old and the new check were useless, but the previous version
> apparently did not lead to the warning.
>
> Rephrase this again by adding a cast. The check is still always false,
> but the compiler shuts up about it.
I think it would be better to just drop the useless part of these tests.
Shaggy
>
> Fixes: cafc6679824a ("jfs: replace hardcoded magic number with DTPAGEMAXSLOT constant")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> fs/jfs/jfs_dtree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
> index 0ab83bb7bbdf..e3301e5fa037 100644
> --- a/fs/jfs/jfs_dtree.c
> +++ b/fs/jfs/jfs_dtree.c
> @@ -2903,7 +2903,7 @@ int jfs_readdir(struct file *file, struct dir_context *ctx)
> stbl = DT_GETSTBL(p);
>
> for (i = index; i < p->header.nextindex; i++) {
> - if (stbl[i] < 0 || stbl[i] >= DTPAGEMAXSLOT) {
> + if (stbl[i] < 0 || (unsigned char)stbl[i] >= DTPAGEMAXSLOT) {
> jfs_err("JFS: Invalid stbl[%d] = %d for inode %ld, block = %lld",
> i, stbl[i], (long)ip->i_ino, (long long)bn);
> free_page(dirent_buf);
> @@ -3108,7 +3108,7 @@ static int dtReadFirst(struct inode *ip, struct btstack * btstack)
> /* get the leftmost entry */
> stbl = DT_GETSTBL(p);
>
> - if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
> + if (stbl[0] < 0 || (unsigned char)stbl[0] >= DTPAGEMAXSLOT) {
> DT_PUTPAGE(mp);
> jfs_error(ip->i_sb, "stbl[0] out of bound\n");
> return -EIO;
next prev parent reply other threads:[~2026-02-02 17:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-02 9:49 Arnd Bergmann
2026-02-02 17:34 ` Dave Kleikamp [this message]
2026-02-02 20:44 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fd1854c2-d3f1-4901-8b7d-c6ce944caf61@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=duttaditya18@gmail.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=justinstitt@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=r.smirnov@omp.ru \
--cc=shaggy@kernel.org \
--cc=zheng.yu@northwestern.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®