public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning again
@ 2026-03-16 14:42 Arnd Bergmann
  2026-03-16 15:20 ` [Jfs-discussion] " Dave Kleikamp
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-03-16 14:42 UTC (permalink / raw)
  To: Dave Kleikamp, Nathan Chancellor, Yun Zhou
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Aditya Dutt, Zheng Yu, jfs-discussion, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

The comparison of an __s8 value against DTPAGEMAXSLOT is still trivially
true, causing a harmless (default disabled) warning with clang:

fs/jfs/jfs_dtree.c:4419:25: 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]
 4419 |                                         p->header.freelist >= DTPAGEMAXSLOT)) {
      |                                         ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~

I previously worked around two of these in commit 7833570dae83 ("jfs: avoid
-Wtautological-constant-out-of-range-compare warning"), but now a new one has
come up, so address the same way by dropping the redundant range check.

Fixes: 119e448bb50a ("jfs: add dtpage integrity check to prevent index/pointer overflows")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/jfs/jfs_dtree.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index 7669e268fe35..a32c78d1c416 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -4415,8 +4415,7 @@ bool check_dtpage(dtpage_t *p)
 		/* When there are free slots, freelist must be a valid slot index in
 		 * 1~DTROOTMAXSLOT-1(since slot[0] is occupied by the header).
 		 */
-		if (unlikely(p->header.freelist < 1 ||
-					p->header.freelist >= DTPAGEMAXSLOT)) {
+		if (unlikely(p->header.freelist < 1)) {
 			jfs_err("Bad freelist:%d in dtpage\n", p->header.freelist);
 			return false;
 		}
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Jfs-discussion] [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning again
  2026-03-16 14:42 [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning again Arnd Bergmann
@ 2026-03-16 15:20 ` Dave Kleikamp
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2026-03-16 15:20 UTC (permalink / raw)
  To: Arnd Bergmann, Nathan Chancellor, Yun Zhou
  Cc: jfs-discussion, llvm, Arnd Bergmann, Nick Desaulniers,
	linux-kernel, Bill Wendling, Justin Stitt, Zheng Yu, Aditya Dutt

On 3/16/26 9:42AM, Arnd Bergmann via Jfs-discussion wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The comparison of an __s8 value against DTPAGEMAXSLOT is still trivially
> true, causing a harmless (default disabled) warning with clang:
> 
> fs/jfs/jfs_dtree.c:4419:25: 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]
>   4419 |                                         p->header.freelist >= DTPAGEMAXSLOT)) {
>        |                                         ~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~
> 
> I previously worked around two of these in commit 7833570dae83 ("jfs: avoid
> -Wtautological-constant-out-of-range-compare warning"), but now a new one has
> come up, so address the same way by dropping the redundant range check.

Thanks. I'm going to remove the comment above it as well, since it 
really isn't helpful.

> 
> Fixes: 119e448bb50a ("jfs: add dtpage integrity check to prevent index/pointer overflows")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   fs/jfs/jfs_dtree.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
> index 7669e268fe35..a32c78d1c416 100644
> --- a/fs/jfs/jfs_dtree.c
> +++ b/fs/jfs/jfs_dtree.c
> @@ -4415,8 +4415,7 @@ bool check_dtpage(dtpage_t *p)
>   		/* When there are free slots, freelist must be a valid slot index in
>   		 * 1~DTROOTMAXSLOT-1(since slot[0] is occupied by the header).
>   		 */
> -		if (unlikely(p->header.freelist < 1 ||
> -					p->header.freelist >= DTPAGEMAXSLOT)) {
> +		if (unlikely(p->header.freelist < 1)) {
>   			jfs_err("Bad freelist:%d in dtpage\n", p->header.freelist);
>   			return false;
>   		}


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-16 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16 14:42 [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning again Arnd Bergmann
2026-03-16 15:20 ` [Jfs-discussion] " Dave Kleikamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox