Skip to content

Commit f4a736a

Browse files
committed
chore: adopt better keycmp() implementation
1 parent da54cce commit f4a736a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

apfs-label/apfs-label.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ static void omap_node_locate_val(struct apfs_btree_node_phys *node, int index, i
222222
static int omap_keycmp(struct apfs_omap_key *k1, struct apfs_omap_key *k2)
223223
{
224224
if (le64_to_cpu(k1->ok_oid) != le64_to_cpu(k2->ok_oid))
225-
return le64_to_cpu(k1->ok_oid) < le64_to_cpu(k2->ok_oid) ? -1 : 1;
225+
return le64_to_cpu(k1->ok_oid) - le64_to_cpu(k2->ok_oid);
226226
if (le64_to_cpu(k1->ok_xid) != le64_to_cpu(k2->ok_xid))
227-
return le64_to_cpu(k1->ok_xid) < le64_to_cpu(k2->ok_xid) ? -1 : 1;
227+
return le64_to_cpu(k1->ok_xid) - le64_to_cpu(k2->ok_xid);
228228
return 0;
229229
}
230230

apfsck/key.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ void read_free_queue_key(void *raw, int size, struct key *key)
7272
int keycmp(struct key *k1, struct key *k2)
7373
{
7474
if (k1->id != k2->id)
75-
return k1->id < k2->id ? -1 : 1;
75+
return k1->id - k2->id;
7676
if (k1->type != k2->type)
77-
return k1->type < k2->type ? -1 : 1;
77+
return k1->type - k2->type;
7878
if (k1->number != k2->number)
79-
return k1->number < k2->number ? -1 : 1;
79+
return k1->number - k2->number;
8080
if (!k1->name) /* Keys of this type have no name */
8181
return 0;
8282

0 commit comments

Comments
 (0)