More consistent use of TREE_* macros in AVL comparators

Where is it appropriate and obvious, use TREE_CMP(), TREE_ISIGN() and
TREE_PCMP() instead or direct comparisons. It can make the code a lot
smaller, less error prone, and easier to read.

Sponsored-by: TrueNAS
Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@truenas.com>
Closes #18259
This commit is contained in:
Rob Norris
2026-03-04 04:08:23 +11:00
committed by GitHub
parent 0f90a797dd
commit 1e2c94a043
19 changed files with 88 additions and 199 deletions
+6 -4
View File
@@ -57,10 +57,12 @@ zfs_refcount_compare(const void *x1, const void *x2)
const reference_t *r1 = (const reference_t *)x1;
const reference_t *r2 = (const reference_t *)x2;
int cmp1 = TREE_CMP(r1->ref_holder, r2->ref_holder);
int cmp2 = TREE_CMP(r1->ref_number, r2->ref_number);
int cmp = cmp1 ? cmp1 : cmp2;
return ((cmp || r1->ref_search) ? cmp : TREE_PCMP(r1, r2));
int cmp = TREE_CMP(r1->ref_holder, r2->ref_holder);
if (cmp == 0)
cmp = TREE_CMP(r1->ref_number, r2->ref_number);
if (cmp | r1->ref_search)
return (cmp);
return (TREE_PCMP(r1, r2));
}
void