From a92101631c0dd2c466dfe22ffd752b36929b2f69 Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 27 Nov 2023 14:40:02 +0100 Subject: [PATCH] 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 --- lib.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- 2.30.2