From: Felix Fietkau Date: Mon, 27 Nov 2023 13:40:02 +0000 (+0100) Subject: lib: fix avl tree lookup X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=a92101631c0dd2c466dfe22ffd752b36929b2f69;p=project%2Fudebug.git 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 --- 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