From f4a736a1384c5c2cfb91525a952e79338758fb0c Mon Sep 17 00:00:00 2001 From: Integral Date: Sat, 18 Jan 2025 22:31:32 +0800 Subject: [PATCH] chore: adopt better keycmp() implementation --- apfs-label/apfs-label.c | 4 ++-- apfsck/key.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/apfs-label/apfs-label.c b/apfs-label/apfs-label.c index 80d74db..d682d48 100644 --- a/apfs-label/apfs-label.c +++ b/apfs-label/apfs-label.c @@ -222,9 +222,9 @@ static void omap_node_locate_val(struct apfs_btree_node_phys *node, int index, i static int omap_keycmp(struct apfs_omap_key *k1, struct apfs_omap_key *k2) { if (le64_to_cpu(k1->ok_oid) != le64_to_cpu(k2->ok_oid)) - return le64_to_cpu(k1->ok_oid) < le64_to_cpu(k2->ok_oid) ? -1 : 1; + return le64_to_cpu(k1->ok_oid) - le64_to_cpu(k2->ok_oid); if (le64_to_cpu(k1->ok_xid) != le64_to_cpu(k2->ok_xid)) - return le64_to_cpu(k1->ok_xid) < le64_to_cpu(k2->ok_xid) ? -1 : 1; + return le64_to_cpu(k1->ok_xid) - le64_to_cpu(k2->ok_xid); return 0; } diff --git a/apfsck/key.c b/apfsck/key.c index fdd09b6..a3eab0d 100644 --- a/apfsck/key.c +++ b/apfsck/key.c @@ -72,11 +72,11 @@ void read_free_queue_key(void *raw, int size, struct key *key) int keycmp(struct key *k1, struct key *k2) { if (k1->id != k2->id) - return k1->id < k2->id ? -1 : 1; + return k1->id - k2->id; if (k1->type != k2->type) - return k1->type < k2->type ? -1 : 1; + return k1->type - k2->type; if (k1->number != k2->number) - return k1->number < k2->number ? -1 : 1; + return k1->number - k2->number; if (!k1->name) /* Keys of this type have no name */ return 0;