From 901afe107a24b24c9fd019b5881afb5966b38665 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 26 Oct 2010 20:54:11 -0500 Subject: [svn-r19671] Description: Bring r19668 from trunk to 1.8 branch: Do some extra range-checking on H5Pset_elink_acc_flags() calls. Clean up some minor compiler warnings also. Tested on: Mac OS X/32 10.6.4 (amazon) w/debug & production (too minor to require h5committest) --- src/H5Bdbg.c | 16 +++++++++------- test/links.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/H5Bdbg.c b/src/H5Bdbg.c index 55d9617..23ea9c8 100644 --- a/src/H5Bdbg.c +++ b/src/H5Bdbg.c @@ -177,7 +177,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void H5RC_t *rc_shared; /* Ref-counted shared info */ H5B_shared_t *shared; /* Pointer to shared B-tree info */ H5B_cache_ud_t cache_udata; /* User-data for metadata cache callback */ - int i, ncell, cmp; + int ncell, cmp; static int ncalls = 0; herr_t status; herr_t ret_value = SUCCEED; /* Return value */ @@ -210,7 +210,7 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void HDassert(bt); shared = (H5B_shared_t *)H5RC_GET_OBJ(bt->rc_shared); HDassert(shared); - cur = H5MM_calloc(sizeof(struct child_t)); + cur = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(cur); cur->addr = addr; cur->level = bt->level; @@ -242,24 +242,26 @@ H5B_assert(H5F_t *f, hid_t dxpl_id, haddr_t addr, const H5B_class_t *type, void HDassert(!H5F_addr_defined(bt->left)); if(cur->level > 0) { - for(i = 0; i < bt->nchildren; i++) { + unsigned u; + + for(u = 0; u < bt->nchildren; u++) { /* * Check that child nodes haven't already been seen. If they * have then the tree has a cycle. */ for(tmp = head; tmp; tmp = tmp->next) - HDassert(H5F_addr_ne(tmp->addr, bt->child[i])); + HDassert(H5F_addr_ne(tmp->addr, bt->child[u])); /* Add the child node to the end of the queue */ - tmp = H5MM_calloc(sizeof(struct child_t)); + tmp = (struct child_t *)H5MM_calloc(sizeof(struct child_t)); HDassert(tmp); - tmp->addr = bt->child[i]; + tmp->addr = bt->child[u]; tmp->level = bt->level - 1; tail->next = tmp; tail = tmp; /* Check that the keys are monotonically increasing */ - cmp = (type->cmp2)(H5B_NKEY(bt, shared, i), udata, H5B_NKEY(bt, shared, i + 1)); + cmp = (type->cmp2)(H5B_NKEY(bt, shared, u), udata, H5B_NKEY(bt, shared, u + 1)); HDassert(cmp < 0); } /* end for */ } /* end if */ diff --git a/test/links.c b/test/links.c index 6b035d1..8e24515 100644 --- a/test/links.c +++ b/test/links.c @@ -4033,6 +4033,7 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; + herr_t ret; unsigned flags; if(new_format) @@ -4083,6 +4084,24 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) } H5E_END_TRY; if(subgroup != FAIL) TEST_ERROR + /* Attempt to set invalid flags on gapl */ + H5E_BEGIN_TRY { + ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_TRUNC); + } H5E_END_TRY; + if(ret != FAIL) TEST_ERROR + H5E_BEGIN_TRY { + ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_EXCL); + } H5E_END_TRY; + if(ret != FAIL) TEST_ERROR + H5E_BEGIN_TRY { + ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_DEBUG); + } H5E_END_TRY; + if(ret != FAIL) TEST_ERROR + H5E_BEGIN_TRY { + ret = H5Pset_elink_acc_flags(gapl, H5F_ACC_CREAT); + } H5E_END_TRY; + if(ret != FAIL) TEST_ERROR + /* Close file1 and group */ if(H5Gclose(group) < 0) TEST_ERROR if(H5Fclose(file1) < 0) TEST_ERROR -- cgit v0.12