public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [v2] jfs: avoid -Wtautological-constant-out-of-range-compare warning
@ 2026-02-02 20:43 Arnd Bergmann
  2026-02-02 21:40 ` Dave Kleikamp
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-02-02 20:43 UTC (permalink / raw)
  To: Dave Kleikamp, Nathan Chancellor, Zheng Yu
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Roman Smirnov, Aditya Dutt, jfs-discussion, linux-kernel, llvm

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.

Remove the extraneous range check for simplicity.

Fixes: cafc6679824a ("jfs: replace hardcoded magic number with DTPAGEMAXSLOT constant")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: drop the check instead of shutting up the warning
---
 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..9ab3f2fc61d1 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) {
 				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) {
 			DT_PUTPAGE(mp);
 			jfs_error(ip->i_sb, "stbl[0] out of bound\n");
 			return -EIO;
-- 
2.39.5


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

* Re: [PATCH] [v2] jfs: avoid -Wtautological-constant-out-of-range-compare warning
  2026-02-02 20:43 [PATCH] [v2] jfs: avoid -Wtautological-constant-out-of-range-compare warning Arnd Bergmann
@ 2026-02-02 21:40 ` Dave Kleikamp
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2026-02-02 21:40 UTC (permalink / raw)
  To: Arnd Bergmann, Nathan Chancellor, Zheng Yu
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Roman Smirnov, Aditya Dutt, jfs-discussion, linux-kernel, llvm

On 2/2/26 2:43PM, 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.
> 
> Remove the extraneous range check for simplicity.
> 
> Fixes: cafc6679824a ("jfs: replace hardcoded magic number with DTPAGEMAXSLOT constant")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: drop the check instead of shutting up the warning

Looks good. I'll put this into jfs-next.

> ---
>   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..9ab3f2fc61d1 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) {
>   				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) {
>   			DT_PUTPAGE(mp);
>   			jfs_error(ip->i_sb, "stbl[0] out of bound\n");
>   			return -EIO;


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

end of thread, other threads:[~2026-02-02 21:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 20:43 [PATCH] [v2] jfs: avoid -Wtautological-constant-out-of-range-compare warning Arnd Bergmann
2026-02-02 21:40 ` Dave Kleikamp

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