From aa305b466b6dcb5a56d305f272e3c2b980e9963b Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Mon, 6 May 2002 11:03:55 -0500 Subject: [svn-r5358] Purpose: bug fix Description: In H5TB.c, previously use an unsigned variable to represent address difference that is maybe a negative value. This will cause a potential bug in the future when this section of code is run. Solution: use H5F_address_cmp macro to compare two addresses. Platforms tested: linux 2.2.18 --- src/H5TB.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/H5TB.c b/src/H5TB.c index e4a1488..1ff5027 100644 --- a/src/H5TB.c +++ b/src/H5TB.c @@ -60,6 +60,7 @@ #include "H5private.h" /*library */ #include "H5Eprivate.h" /*error handling */ +#include "H5Fprivate.h" /* File address macros */ #include "H5MMprivate.h" /*Core memory management */ #include "H5FLprivate.h" /*Free Lists */ #include "H5TBprivate.h" /*Threaded, balanced, binary trees */ @@ -1154,7 +1155,6 @@ H5TB_ffind(H5TB_NODE * root, void * key, unsigned fast_compare, H5TB_NODE ** pp) H5TB_NODE *parent = NULL; int side; int cmp = 1; - haddr_t cmp_addr = 1; H5TB_NODE *ret_value = NULL; FUNC_ENTER (H5TB_ffind, NULL); @@ -1162,9 +1162,9 @@ H5TB_ffind(H5TB_NODE * root, void * key, unsigned fast_compare, H5TB_NODE ** pp) switch(fast_compare) { case H5TB_FAST_HADDR_COMPARE: if (ptr) { - while (0 != (cmp_addr = (*(haddr_t *)key - *(haddr_t *)ptr->key))) { + while (0 != (cmp = H5F_addr_cmp(*(haddr_t *)key,*(haddr_t *)ptr->key))) { parent = ptr; - side = (cmp_addr < 0) ? LEFT : RIGHT; + side = (cmp < 0) ? LEFT : RIGHT; if (!HasChild(ptr, side)) break; ptr = ptr->link[side]; @@ -1174,7 +1174,7 @@ H5TB_ffind(H5TB_NODE * root, void * key, unsigned fast_compare, H5TB_NODE ** pp) *pp = parent; /* Set return value */ - ret_value= (0 == cmp_addr) ? ptr : NULL; + ret_value= (0 == cmp) ? ptr : NULL; break; case H5TB_FAST_INTN_COMPARE: -- cgit v0.12