[PATCH 11/21] Fix return value of cmp_ihdr_off()

Valerie Aurora val at versity.com
Tue Feb 11 13:19:08 PST 2025


From: Zach Brown <zab at versity.com>

Comparing item headers was doing b - a instead of a - b, resulting in
wildly out of order headers.

Co-authored-by: Valerie Aurora <val at versity.com>
Signed-off-by: Zach Brown <zab at versity.com>
Signed-off-by: Valerie Aurora <val at versity.com>
---
 shared/btree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/shared/btree.c b/shared/btree.c
index 7987270..b96a912 100644
--- a/shared/btree.c
+++ b/shared/btree.c
@@ -313,7 +313,7 @@ static int cmp_ihdr_off(const void *A, const void *B, const void *priv)
 	const struct ngnfs_btree_item_header *a = &bt->ihdrs[*(u16 *)A];
 	const struct ngnfs_btree_item_header *b = &bt->ihdrs[*(u16 *)B];
 
-	return (int)le16_to_cpu(b->off) - (int)le16_to_cpu(a->off);
+	return (int)le16_to_cpu(a->off) - (int)le16_to_cpu(b->off);
 }
 
 /*
-- 
2.48.1




More information about the ngnfs-devel mailing list