diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-09 22:39:43 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2010-02-09 22:39:43 (GMT) |
commit | c5c85080a7d1dcae35cffba922d88320a2475ec8 (patch) | |
tree | 64fe3bdcbe1216f26757a50c1811657a2fd05f0f /test/tfile.c | |
parent | cc1c7331a5f57b1d8beae65c257164e11060ebef (diff) | |
download | hdf5-c5c85080a7d1dcae35cffba922d88320a2475ec8.zip hdf5-c5c85080a7d1dcae35cffba922d88320a2475ec8.tar.gz hdf5-c5c85080a7d1dcae35cffba922d88320a2475ec8.tar.bz2 |
[svn-r18225] Description:
Bring r18244 from trunk to 1.8 branch:
Bring revisions from Coverity session from hdf5_1_8_coverity branch to
trunk:
r18214:
Issue 423: cache_ptr was not initialized. if global 'pass' was false,
cache_ptr could be used. Extended scope of if(pass) block to include whole
function-flush_cache().
r18215:
Fix coverity item 317. Removed unreachable code in H5B2_hdr_alloc.
r18216:
Fixed Coverity issues 57 & 67. Checked oid_count > 0 before memory allocation
and oid_list != NULL before dereferencing.
Tested on:
Mac OS X/32 10.6.2 (amazon) w/debug & production
(daily tested on Coverity branch already)
Diffstat (limited to 'test/tfile.c')
-rw-r--r-- | test/tfile.c | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/test/tfile.c b/test/tfile.c index d080b4a..3992c47 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1119,46 +1119,46 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL); CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_8, "H5Fget_obj_count"); + + if(oid_count > 0) { + hid_t *oid_list; - { - hid_t *oid_list; - int i; - H5I_type_t id_type; - - oid_list = (hid_t*)calloc((size_t)oid_count, sizeof(hid_t)); + oid_list = (hid_t *)HDcalloc((size_t)oid_count, sizeof(hid_t)); if(oid_list != NULL) { + int i; + ret_count = H5Fget_obj_ids(H5F_OBJ_ALL, H5F_OBJ_ALL, (size_t)oid_count, oid_list); CHECK(ret_count, FAIL, "H5Fget_obj_ids"); - } - - for(i=0; i<oid_count; i++) { - id_type = H5Iget_type(oid_list[i]); - switch(id_type) { - case H5I_FILE: - if(oid_list[i]!=fid1 && oid_list[i]!=fid2 && - oid_list[i]!=fid3 && oid_list[i]!=fid4) { - ret = FAIL; - CHECK(ret, FAIL, "H5Fget_obj_ids"); - } - break; - case H5I_GROUP: - if(oid_list[i]!=gid1 && oid_list[i]!=gid2 && - oid_list[i]!=gid3) { - ret = FAIL; - CHECK(ret, FAIL, "H5Fget_obj_ids"); - } - break; - case H5I_DATASET: - VERIFY(oid_list[i], did, "H5Fget_obj_ids"); - break; - default: - ret = FAIL; - CHECK(ret, FAIL, "H5Fget_obj_ids"); - } - } - - free(oid_list); - } + + for(i = 0; i < oid_count; i++) { + H5I_type_t id_type; + + id_type = H5Iget_type(oid_list[i]); + switch(id_type) { + case H5I_FILE: + if(oid_list[i] != fid1 && oid_list[i] != fid2 + && oid_list[i] != fid3 && oid_list[i] != fid4) + ERROR("H5Fget_obj_ids"); + break; + + case H5I_GROUP: + if(oid_list[i] != gid1 && oid_list[i] != gid2 + && oid_list[i] != gid3) + ERROR("H5Fget_obj_ids"); + break; + + case H5I_DATASET: + VERIFY(oid_list[i], did, "H5Fget_obj_ids"); + break; + + default: + ERROR("H5Fget_obj_ids"); + } /* end switch */ + } /* end for */ + + HDfree(oid_list); + } /* end if */ + } /* end if */ /* close the two new files */ ret = H5Fclose(fid3); |