[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250708022453.GB1845251@mit.edu>
Date: Mon, 7 Jul 2025 22:24:53 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: I Hsin Cheng <richard120310@...il.com>
Cc: adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org, skhan@...uxfoundation.org,
linux-kernel-mentees@...ts.linuxfoundation.org
Subject: Re: [PATCH] ext4: Refactor breaking condition for xattr_find_entry()
On Tue, Jul 08, 2025 at 10:00:13AM +0800, I Hsin Cheng wrote:
> diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
> index 8d15acbacc20..1993622e3c74 100644
> --- a/fs/ext4/xattr.c
> +++ b/fs/ext4/xattr.c
> @@ -338,7 +338,7 @@ xattr_find_entry(struct inode *inode, struct ext4_xattr_entry **pentry,
> cmp = name_len - entry->e_name_len;
> if (!cmp)
> cmp = memcmp(name, entry->e_name, name_len);
> - if (cmp <= 0 && (sorted || cmp == 0))
> + if (!cmp || (cmp < 0 && sorted))
This is *not* identical. Suppose memcmp returns a positive value
(say, 1). Previously, the conditional would be false. With your
change, !cmp would be true, so the overall conditional would be true.
So this does not appear to be a valid transformation.
(Note that valid transformations will be done by the compiler
automatically, without needing to make code changes.)
- Ted
Powered by blists - more mailing lists