diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 12:36:56 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-10 12:36:56 (GMT) |
commit | 34d14bdf89d63023dfeb5ff471b71e5b591faa31 (patch) | |
tree | 64aa9fbfe2b3e011b55b39c70b4f85cc28c3a9c9 /test/unlink.c | |
parent | adce7dfd846901f3164d446cf7443747ddefc492 (diff) | |
download | hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.zip hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.gz hdf5-34d14bdf89d63023dfeb5ff471b71e5b591faa31.tar.bz2 |
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
Diffstat (limited to 'test/unlink.c')
-rw-r--r-- | test/unlink.c | 76 |
1 files changed, 62 insertions, 14 deletions
diff --git a/test/unlink.c b/test/unlink.c index 60d6ac5..9bd6f42 100644 --- a/test/unlink.c +++ b/test/unlink.c @@ -1487,8 +1487,8 @@ delete_node(hid_t pid, hid_t id) static int test_unlink_rightleaf(hid_t fid) { - hid_t rootid, /* Group ID for root group */ - *gids; /* Array of IDs for groups created */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ int n, /* Local index variable */ ngroups = 150; /* Number of groups to create */ char name[256]; /* Name of object to create */ @@ -1496,7 +1496,7 @@ test_unlink_rightleaf(hid_t fid) TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR + if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1514,8 +1514,10 @@ test_unlink_rightleaf(hid_t fid) } /* end for */ /* Close all the groups */ - for (n = 0; n < ngroups; n++) + for (n = 0; n < ngroups; n++) { if(H5Gclose(gids[n]) < 0) TEST_ERROR + gids[n] = 0; + } /* end for */ /* Close root group ID */ if(H5Gclose(rootid) < 0) TEST_ERROR @@ -1527,6 +1529,20 @@ test_unlink_rightleaf(hid_t fid) return 0; error: + if(gids) { + /* Close any open groups */ + for (n = 0; n < ngroups; n++) + if(gids[n]) { + H5E_BEGIN_TRY { + H5Gclose(gids[n]); + } H5E_END_TRY; + } /* end if */ + HDfree(gids); + } /* end if */ + H5E_BEGIN_TRY { + H5Gclose(rootid); + } H5E_END_TRY; + return 1; } /* end test_unlink_rightleaf() */ @@ -1550,8 +1566,8 @@ error: static int test_unlink_rightnode(hid_t fid) { - hid_t rootid, /* Group ID for root group */ - *gids; /* Array of IDs for groups created */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ int n, /* Local index variable */ ngroups = 150; /* Number of groups to create */ char name[256]; /* Name of object to create */ @@ -1559,7 +1575,7 @@ test_unlink_rightnode(hid_t fid) TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR + if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1570,8 +1586,10 @@ test_unlink_rightnode(hid_t fid) } /* end for */ /* Close all the groups */ - for (n = 0; n < ngroups; n++) + for (n = 0; n < ngroups; n++) { if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR + gids[n] = 0; + } /* end for */ /* Unlink specific objects to trigger deletion of right leaf in non-leaf node */ if(H5Ldelete(fid, "/ZoneB77", H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -1590,6 +1608,20 @@ test_unlink_rightnode(hid_t fid) return 0; error: + if(gids) { + /* Close any open groups */ + for (n = 0; n < ngroups; n++) + if(gids[n]) { + H5E_BEGIN_TRY { + H5Gclose(gids[n]); + } H5E_END_TRY; + } /* end if */ + HDfree(gids); + } /* end if */ + H5E_BEGIN_TRY { + H5Gclose(rootid); + } H5E_END_TRY; + return 1; } /* end test_unlink_rightnode() */ @@ -1613,8 +1645,8 @@ error: static int test_unlink_middlenode(hid_t fid) { - hid_t rootid, /* Group ID for root group */ - *gids; /* Array of IDs for groups created */ + hid_t rootid = -1, /* Group ID for root group */ + *gids = NULL; /* Array of IDs for groups created */ int n, /* Local index variable */ ngroups = 250; /* Number of groups to create */ char name[256]; /* Name of object to create */ @@ -1622,7 +1654,7 @@ test_unlink_middlenode(hid_t fid) TESTING("deleting right-most child in non-leaf B-tree node"); /* Allocate space for the group IDs */ - if(NULL == (gids = (hid_t *)HDmalloc((size_t)ngroups * sizeof(hid_t)))) TEST_ERROR + if(NULL == (gids = (hid_t *)HDcalloc((size_t)ngroups, sizeof(hid_t)))) TEST_ERROR if((rootid = H5Gopen2(fid, "/", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR @@ -1633,8 +1665,10 @@ test_unlink_middlenode(hid_t fid) } /* end for */ /* Close all the groups */ - for (n = 0; n < ngroups; n++) + for (n = 0; n < ngroups; n++) { if(H5Gclose(gids[n]) < 0) FAIL_STACK_ERROR + gids[n] = 0; + } /* end for */ /* Unlink specific objects to trigger deletion of all leafs in "interior" non-leaf node */ if(H5Ldelete(fid, "/ZoneC11", H5P_DEFAULT) < 0) FAIL_STACK_ERROR @@ -1796,6 +1830,20 @@ test_unlink_middlenode(hid_t fid) return 0; error: + if(gids) { + /* Close any open groups */ + for (n = 0; n < ngroups; n++) + if(gids[n]) { + H5E_BEGIN_TRY { + H5Gclose(gids[n]); + } H5E_END_TRY; + } /* end if */ + HDfree(gids); + } /* end if */ + H5E_BEGIN_TRY { + H5Gclose(rootid); + } H5E_END_TRY; + return 1; } /* end test_unlink_middlenode() */ @@ -1819,7 +1867,7 @@ error: static int test_resurrect_dataset(hid_t fapl) { - hid_t f =-1, s =-1, d =-1; + hid_t f = -1, s = -1, d = -1; char filename[1024]; TESTING("resurrecting dataset after deletion"); @@ -2404,7 +2452,7 @@ main(void) double rdcc_w0; /* Set the random # seed */ - HDsrandom((unsigned long)HDtime(NULL)); + HDsrandom((unsigned)HDtime(NULL)); /* Open */ h5_reset(); |