summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau2023-11-27 13:40:02 +0000
committerFelix Fietkau2023-11-27 13:40:05 +0000
commita92101631c0dd2c466dfe22ffd752b36929b2f69 (patch)
tree4fe53498e34f91d0d7711f5ad0d90d6b7c4bd54f
parentcb71f64de0eca864285e3c472b5ca4449c43ee29 (diff)
lib: fix avl tree lookup
The delta between IDs can be bigger than INT_MAX, causing order mismatch in the tree and lookup failures Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r--lib.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib.c b/lib.c
index ec8c23d..caba7d9 100644
--- a/lib.c
+++ b/lib.c
@@ -37,7 +37,11 @@ static void __randname(char *template)
int udebug_id_cmp(const void *k1, const void *k2, void *ptr)
{
uint32_t id1 = (uint32_t)(uintptr_t)k1, id2 = (uint32_t)(uintptr_t)k2;
- return id1 - id2;
+ if (id1 < id2)
+ return -1;
+ else if (id1 > id2)
+ return 1;
+ return 0;
}
static inline int