From b757e8f9ace4b56418ecacf0376971bea847fa4f Mon Sep 17 00:00:00 2001 From: MuQun Yang Date: Mon, 6 May 2002 11:44:06 -0500 Subject: [svn-r5359] Purpose: 1. code clean-up 2. bug fix Description: 1. windows complian data casting from large size to small size use H5_ASSIGN_OVERFLOW and H5_CHECK_OVERFLOW to erase some warnings 2. in H5TB.c, cmp_addr is used to compare two different address. However, cmp_addr is defined as an unsigned integer which may cause problems when the difference is negative. Solution: 2. Use H5Fcmp_address macro to replace cmp_addr in H5TB.c. Platforms tested: linux 2.2.18 and windows 2000 --- src/H5Shyper.c | 4 +++- src/H5TB.c | 8 ++++---- src/H5Tconv.c | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index bfe53a3..e5b828c 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -493,7 +493,8 @@ H5S_hyper_block_read (H5S_hyper_node_t *node, H5S_hyper_io_info_t *io_info, hsiz * offset */ node->cinfo.rpos+=region_size*io_info->elmt_size; - node->cinfo.rleft-=region_size; + H5_ASSIGN_OVERFLOW(node->cinfo.rleft,node->cinfo.rleft-region_size,hsize_t,size_t); + /* node->cinfo.rleft-=region_size;*/ /* If we've read in all the elements from the block, throw it away */ if(node->cinfo.rleft==0 && (node->cinfo.wleft==0 || node->cinfo.wleft==node->cinfo.size)) { @@ -547,6 +548,7 @@ H5S_hyper_block_write (H5S_hyper_node_t *node, * offset */ node->cinfo.wpos+=region_size*io_info->elmt_size; + H5_ASSIGN_OVERFLOW(node->cinfo.wleft,node->cinfo.wleft-region_size,hsize_t,size_t); node->cinfo.wleft-=region_size; /* If we've read in all the elements from the block, throw it away */ diff --git a/src/H5TB.c b/src/H5TB.c index 016728b..6b92d1f 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: diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 6db7550..0a6a49a 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -1465,8 +1465,8 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, hsize_t nelmts, src_delta = src->size; bkg_stride = dst->size; } else { - src_delta = -(src->size); - bkg_stride = -(dst->size); + src_delta = -(int)(src->size);/*overflow shouldn't be possible */ + bkg_stride = -(int)(dst->size);/*overflow shouldn't be possible */ xbuf += (nelmts-1) * src->size; xbkg += (nelmts-1) * dst->size; } -- cgit v0.12