diff mbox series

[13/27] xfs_repair: tidy up rmap_diffkeys

Message ID 173888088295.2741033.4604651348658562209.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [01/27] libxfs: compute the rt rmap btree maxlevels during initialization | expand

Commit Message

Darrick J. Wong Feb. 6, 2025, 10:53 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Tidy up the comparison code in this function to match the kernel.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 repair/rmap.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Christoph Hellwig Feb. 7, 2025, 5:20 a.m. UTC | #1
On Thu, Feb 06, 2025 at 02:53:07PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Tidy up the comparison code in this function to match the kernel.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Or do you want to use the fancy cmp_int() helper?
diff mbox series

Patch

diff --git a/repair/rmap.c b/repair/rmap.c
index bd91c721e20e4e..2065bdc0b190ba 100644
--- a/repair/rmap.c
+++ b/repair/rmap.c
@@ -1267,7 +1267,6 @@  rmap_diffkeys(
 {
 	__u64			oa;
 	__u64			ob;
-	int64_t			d;
 	struct xfs_rmap_irec	tmp;
 
 	tmp = *kp1;
@@ -1277,9 +1276,10 @@  rmap_diffkeys(
 	tmp.rm_flags &= ~XFS_RMAP_REC_FLAGS;
 	ob = libxfs_rmap_irec_offset_pack(&tmp);
 
-	d = (int64_t)kp1->rm_startblock - kp2->rm_startblock;
-	if (d)
-		return d;
+	if (kp1->rm_startblock > kp2->rm_startblock)
+		return 1;
+	else if (kp2->rm_startblock > kp1->rm_startblock)
+		return -1;
 
 	if (kp1->rm_owner > kp2->rm_owner)
 		return 1;