diff options
author | MuQun Yang <ymuqun@hdfgroup.org> | 2002-05-06 16:03:55 (GMT) |
---|---|---|
committer | MuQun Yang <ymuqun@hdfgroup.org> | 2002-05-06 16:03:55 (GMT) |
commit | aa305b466b6dcb5a56d305f272e3c2b980e9963b (patch) | |
tree | af4adc39e603aa66a7bd57662a76ea2c338d753a | |
parent | 2cf0e9f8822bddab983f764ee669656e1ec61f1e (diff) | |
download | hdf5-aa305b466b6dcb5a56d305f272e3c2b980e9963b.zip hdf5-aa305b466b6dcb5a56d305f272e3c2b980e9963b.tar.gz hdf5-aa305b466b6dcb5a56d305f272e3c2b980e9963b.tar.bz2 |
[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
-rw-r--r-- | src/H5TB.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -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: |