diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-03 19:41:48 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2009-12-03 19:41:48 (GMT) |
commit | 77a3cc2292f6021a306372284c20882b8dc8eeeb (patch) | |
tree | 16353ba544c939c32750fef938aee693f3fd05ad /test/links.c | |
parent | 05bdd6d7293128b774eef1590c016c447e6e14ed (diff) | |
download | hdf5-77a3cc2292f6021a306372284c20882b8dc8eeeb.zip hdf5-77a3cc2292f6021a306372284c20882b8dc8eeeb.tar.gz hdf5-77a3cc2292f6021a306372284c20882b8dc8eeeb.tar.bz2 |
[svn-r17954] Description:
Bring r17953 from trunk to 1.8 branch:
Bring Coverity changes into the trunk:
r17877:
Error 266: Uninitialized memspace set to -1. Changed malloc and free to HDmalloc and HDfree. Removed unused dtype var.
r17878:
Error 265: Uninitialized mem_space set to -1. Changed malloc and free to HDmalloc and HDfree.
Error 267: Uninitialized smspace set to -1. Changed malloc and free to HDmalloc and HDfree.
r17879:
Error 242: Uninitialized aid set to -1.
Error 243: Uninitialized sid set to -1.
Uninitialized tid set to -1 for consistency
r17880:
Error 242: reinitialized aid to -1 after close to be ready for reuse.
Error 243: reinitialized sid to -1 after close to be ready for reuse.
reinitialized tid to -1 for consistency after close to be ready for reuse.
r17881:
use valgrind to check there is a memory leak. The fix is to free ptrstr in line 5838 at xml_dump_group() of h5dump.c after it is used. run the valgrind after the fix, no memory leak for that part of the code.
r17882:
Fix Coverity items 256 and 269.
r17883:
Error 222-230: initialized hid_t vars to -1 after close to be ready for reuse.
Also added H5Tclose for tid in gent_bigdims
r17884:
Bug fix (Coverity run2, view 23, dead code)
(this is pair-program done by Albert, Elena and Larry).
Confirmed and fixed the deadcode in hyperslab read branch of function
diff_datasetid.
(Discovered other bad code that diff_datasetid() should be recoded.
Bug 1693 is entered for this.)
r17906:
Fix Coverity item 260.
r17907:
262: Initialized hid_t's dtype, dtype_tmp and file to -1. Initialized H5T_t * dt to NULL.
r17908:
Fix Coverity item 261.
r17909:
Fix Coverity item 248.
r17910:
Revise fix for Coverity item 248.
r17911:
Resolved coverity issues #s 263, 162, 163, 164. All issues in dsets.c. Initialized fid and did hid_t's. filter_corrupt function was returning in the middle of an if statement, bypassing free calls. Updated error handling to free buffers and hid_t's appropriately.
r17912:
(done by Larry and Albert)
Cleanup Coverity view warnings (#231-241) about
using uninitialized variables. Initialized all
of them.
r17913:
Resolved issue 251 and 264. Initialized tid2 to -1 and initialized buffers that were freed in case of an error.
r17914:
Resolved coverity issues 66, 220, and 221:
66: Negative Return assignment ignored
220,221: Initialized hid_t's.
r17915:
Fix Coverity item 247.
r17916:
Fix Coverity item 246.
r17917:
Fix Coverity item 245.
r17918:
Fix Coverity item 244.
r17919:
Coverity Issue #84: Moved asserts in H5T_cmp to the top of the function, and converted them to HDassert. Coverity complaining about using potentially NULL pointer without checking it. Want to see if Coverity will accept Assertions as acceptable checking before using the value.
Tested on:
FreeBSD/32 6.3 (duty) w/debug
(h5committested on trunk)
Diffstat (limited to 'test/links.c')
-rw-r--r-- | test/links.c | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/test/links.c b/test/links.c index 6460789..26381ce 100644 --- a/test/links.c +++ b/test/links.c @@ -3571,8 +3571,8 @@ external_set_elink_fapl1(hid_t fapl, hbool_t new_format) filename2B[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; - hid_t fam_fapl, multi_fapl; - hid_t lapl_idA, lapl_idB; + hid_t fam_fapl=-1, multi_fapl=-1; + hid_t lapl_idA=-1, lapl_idB=-1; H5FD_mem_t mt, memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; char sv[H5FD_MEM_NTYPES][500]; @@ -3769,11 +3769,11 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) { hid_t fid = (-1); /* File ID */ hid_t gid = (-1); /* Group IDs */ + hid_t core_fapl = -1, space = -1, dset = -1, did = -1, dapl_id = -1, dcpl = -1; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE], tmpname[NAME_BUF_SIZE], cwdpath[NAME_BUF_SIZE]; - hid_t core_fapl, space, dset, did, dapl_id, dcpl; hsize_t dims[2]; int points[NUM40][NUM40]; h5_stat_size_t filesize, new_filesize; @@ -3806,8 +3806,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) h5_fixname(FILENAME[39], core_fapl, filename2, sizeof filename2); /* Create the target file to be a "core" file */ - if((fid=H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR - if((gid=H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, core_fapl)) < 0) TEST_ERROR + if((gid = H5Gcreate2(fid, "A", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR dims[0] = NUM40; dims[1] = NUM40; @@ -3848,8 +3848,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) /* try to open the external linked target dataset */ did = H5Dopen2(fid, "ext_link", dapl_id); - - if (did < 0) { + if(did < 0) { H5_FAILED(); puts(" Should succeed in opening the target dataset"); goto error; @@ -3871,7 +3870,7 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) new_filesize = h5_get_file_size(filename2, core_fapl); /* the file size should remain the same since there is no backing store */ - if (new_filesize != filesize) TEST_ERROR + if(new_filesize != filesize) TEST_ERROR if(H5Pclose(core_fapl) < 0) TEST_ERROR @@ -3885,8 +3884,9 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) H5Dclose(dset); H5Pclose(core_fapl); H5Pclose(dapl_id); - H5Dclose (did); - H5Fclose (fid); + H5Dclose(did); + H5Gclose(gid); + H5Fclose(fid); } H5E_END_TRY; return -1; } /* end external_set_elink_fapl2() */ @@ -3926,8 +3926,8 @@ external_set_elink_fapl2(hid_t fapl, hbool_t new_format) static int external_set_elink_fapl3(hbool_t new_format) { - hid_t core_fapl, stdio_fapl; - hid_t lapl_id, new_lapl_id, l_fapl, out_fapl; + hid_t core_fapl = -1, stdio_fapl = -1; + hid_t lapl_id = -1, new_lapl_id = -1, l_fapl = -1, out_fapl; int ret; if(new_format) @@ -3950,43 +3950,43 @@ external_set_elink_fapl3(hbool_t new_format) /* Verify that the driver for the link's fapl is the "stdio" driver */ if((l_fapl = H5Pget_elink_fapl(lapl_id)) < 0) TEST_ERROR - if (H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR - if (H5Pclose(l_fapl) < 0) TEST_ERROR + if(H5Pget_driver(l_fapl) != H5FD_STDIO) TEST_ERROR + if(H5Pclose(l_fapl) < 0) TEST_ERROR /* Set file access property list for link access to use the "core" driver */ if(H5Pset_elink_fapl(lapl_id, core_fapl) < 0) TEST_ERROR /* Make a copy of the link access property */ - if ((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR + if((new_lapl_id = H5Pcopy(lapl_id)) < 0) TEST_ERROR /* get the fapl set in lapl_id */ - if (H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR - if (H5Pclose(lapl_id) < 0) TEST_ERROR + if(H5Pget(lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR + if(H5Pclose(lapl_id) < 0) TEST_ERROR /* Try closing out_fapl should fail since H5Pclose(lapl_id) should also close its fapl */ H5E_BEGIN_TRY { ret = H5Pclose(out_fapl); } H5E_END_TRY; - if (ret != FAIL) TEST_ERROR + if(ret != FAIL) TEST_ERROR /* Verify that the driver for the copied link's fapl is the "core" driver */ if((l_fapl = H5Pget_elink_fapl(new_lapl_id)) < 0) TEST_ERROR - if (H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR + if(H5Pget_driver(l_fapl) != H5FD_CORE) TEST_ERROR /* get the fapl set in new_lapl_id */ - if (H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR - if (H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR + if(H5Pget(new_lapl_id, "external link fapl", &out_fapl) < 0) TEST_ERROR + if(H5Premove(new_lapl_id, "external link fapl") < 0) TEST_ERROR /* Try closing out_fapl should fail since the property is removed from new_lapl_id */ H5E_BEGIN_TRY { ret = H5Pclose(out_fapl); } H5E_END_TRY; - if (ret != FAIL) TEST_ERROR + if(ret != FAIL) TEST_ERROR - if (H5Pclose(l_fapl) < 0) TEST_ERROR - if (H5Pclose(new_lapl_id) < 0) TEST_ERROR - if (H5Pclose(core_fapl) < 0) TEST_ERROR - if (H5Pclose(stdio_fapl) < 0) TEST_ERROR + if(H5Pclose(l_fapl) < 0) TEST_ERROR + if(H5Pclose(new_lapl_id) < 0) TEST_ERROR + if(H5Pclose(core_fapl) < 0) TEST_ERROR + if(H5Pclose(stdio_fapl) < 0) TEST_ERROR PASSED(); return 0; @@ -4021,7 +4021,7 @@ external_set_elink_fapl3(hbool_t new_format) static int external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) { - hid_t file1, file2, group, subgroup, gapl; + hid_t file1 = -1, file2 = -1, group = -1, subgroup = -1, gapl = -1; char filename1[NAME_BUF_SIZE], filename2[NAME_BUF_SIZE]; unsigned flags; @@ -4034,70 +4034,70 @@ external_set_elink_acc_flags(hid_t fapl, hbool_t new_format) /* Create parent and target files, and external link */ h5_fixname(FILENAME[40], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[41], fapl, filename2, sizeof filename2); - if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if (H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if(H5Lcreate_external(filename2, "/", file1, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close file2, leave file1 open (should be read-write) */ - if (H5Fclose(file2) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR /* Create new gapl, and set elink access flags to be H5F_ACC_RDONLY */ - if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR + if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR + if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDONLY) < 0) TEST_ERROR /* Verify "get" routine functionality */ - if (H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR - if (flags != H5F_ACC_RDONLY) TEST_ERROR + if(H5Pget_elink_acc_flags(gapl, &flags) < 0) TEST_ERROR + if(flags != H5F_ACC_RDONLY) TEST_ERROR /* Attempt to create a group through the external link using gapl (should fail) */ H5E_BEGIN_TRY { group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl); } H5E_END_TRY; - if (group != FAIL) TEST_ERROR + if(group != FAIL) TEST_ERROR /* Close file1 and reopen with read only access */ - if (H5Fclose(file1) < 0) TEST_ERROR - if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if(H5Fclose(file1) < 0) TEST_ERROR + if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Set elink access flags on gapl to be H5F_ACC_RDWR */ - if (H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR + if(H5Pset_elink_acc_flags(gapl, H5F_ACC_RDWR) < 0) TEST_ERROR /* Create a group through the external link using gapl (should succeed) */ - if ((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR + if((group = H5Gcreate2(file1, "/ext_link/group", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR /* Unset elink access flags on gapl */ - if (H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR + if(H5Pset_elink_acc_flags(gapl, H5F_ACC_DEFAULT) < 0) TEST_ERROR /* Attempt to create a group through the external link using gapl (should fail) */ H5E_BEGIN_TRY { subgroup = H5Gcreate2(file1, "/ext_link/group/subgroup", H5P_DEFAULT, H5P_DEFAULT, gapl); } H5E_END_TRY; - if (subgroup != FAIL) TEST_ERROR + if(subgroup != FAIL) TEST_ERROR /* Close file1 and group */ - if (H5Gclose(group) < 0) TEST_ERROR - if (H5Fclose(file1) < 0) TEST_ERROR + if(H5Gclose(group) < 0) TEST_ERROR + if(H5Fclose(file1) < 0) TEST_ERROR /* Verify that H5Fcreate and H5Fopen reject H5F_ACC_DEFAULT */ H5E_BEGIN_TRY { file1 = H5Fcreate(filename1, H5F_ACC_DEFAULT, H5P_DEFAULT, fapl); } H5E_END_TRY; - if (file1 != FAIL) TEST_ERROR + if(file1 != FAIL) TEST_ERROR H5E_BEGIN_TRY { file1 = H5Fcreate(filename1, H5F_ACC_TRUNC | H5F_ACC_DEFAULT, H5P_DEFAULT, fapl); } H5E_END_TRY; - if (file1 != FAIL) TEST_ERROR + if(file1 != FAIL) TEST_ERROR H5E_BEGIN_TRY { file1 = H5Fopen(filename1, H5F_ACC_DEFAULT, fapl); } H5E_END_TRY; - if (file1 != FAIL) TEST_ERROR + if(file1 != FAIL) TEST_ERROR H5E_BEGIN_TRY { file1 = H5Fopen(filename1, H5F_ACC_RDWR | H5F_ACC_DEFAULT, fapl); } H5E_END_TRY; - if (file1 != FAIL) TEST_ERROR + if(file1 != FAIL) TEST_ERROR /* Close gapl */ - if (H5Pclose(gapl) < 0) TEST_ERROR + if(H5Pclose(gapl) < 0) TEST_ERROR PASSED(); return 0; @@ -4171,7 +4171,7 @@ external_set_elink_cb_cb(const char *parent_file, const char *parent_group, static int external_set_elink_cb(hid_t fapl, hbool_t new_format) { - hid_t file1, file2, group, gapl, fam_fapl, ret_fapl, base_driver; + hid_t file1 = -1, file2 = -1, group = -1, gapl = -1, fam_fapl = -1, ret_fapl = -1, base_driver; set_elink_cb_t op_data, *op_data_p; H5L_elink_traverse_t cb; @@ -4204,44 +4204,44 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) /* Create parent and target files, group, and external link */ h5_fixname(FILENAME[42], fapl, filename1, sizeof filename1); h5_fixname(FILENAME[43], fam_fapl, filename2, sizeof filename2); - if ((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if ((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR - if ((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR - if (H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR + if((file1 = H5Fcreate(filename1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR + if((file2 = H5Fcreate(filename2, H5F_ACC_TRUNC, H5P_DEFAULT, fam_fapl)) < 0) TEST_ERROR + if((group = H5Gcreate2(file1, "group1",H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR + if(H5Lcreate_external(filename2, "/", group, "ext_link", H5P_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR /* Close files and group */ - if (H5Fclose(file1) < 0) TEST_ERROR - if (H5Fclose(file2) < 0) TEST_ERROR - if (H5Gclose(group) < 0) TEST_ERROR + if(H5Fclose(file1) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR + if(H5Gclose(group) < 0) TEST_ERROR /* Create new gapl, and set elink callback */ - if ((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR - if (H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR + if((gapl = H5Pcreate(H5P_GROUP_ACCESS)) < 0) TEST_ERROR + if(H5Pset_elink_cb(gapl, external_set_elink_cb_cb, &op_data) < 0) TEST_ERROR /* Verify "get" routine functionality */ - if (H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR - if (cb != external_set_elink_cb_cb) TEST_ERROR - if (op_data_p != &op_data) TEST_ERROR + if(H5Pget_elink_cb(gapl, &cb, (void **) &op_data_p) < 0) TEST_ERROR + if(cb != external_set_elink_cb_cb) TEST_ERROR + if(op_data_p != &op_data) TEST_ERROR /* Open file1 with read only access */ - if ((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR + if((file1 = H5Fopen(filename1, H5F_ACC_RDONLY, fapl)) < 0) TEST_ERROR /* Create a group through the external link using gapl */ - if ((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR + if((group = H5Gcreate2(file1, "/group1/ext_link/group2", H5P_DEFAULT, H5P_DEFAULT, gapl)) < 0) TEST_ERROR /* Verify that the correct parameters have been set on file2 (somewhat * redundant as the library would be unable to create the group otherwise) */ - if ((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR - if (H5Fget_intent(file2, &flags) < 0) TEST_ERROR - if (!(flags & H5F_ACC_RDWR)) TEST_ERROR - if ((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR - if (H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR - - if (H5Gclose(group) < 0) TEST_ERROR - if (H5Fclose(file2) < 0) TEST_ERROR - if (H5Pclose(ret_fapl) < 0) TEST_ERROR - if (H5Pclose(fam_fapl) < 0) TEST_ERROR + if((file2 = H5Iget_file_id(group)) < 0) TEST_ERROR + if(H5Fget_intent(file2, &flags) < 0) TEST_ERROR + if(!(flags & H5F_ACC_RDWR)) TEST_ERROR + if((ret_fapl = H5Fget_access_plist(file2)) < 0) TEST_ERROR + if(H5FD_FAMILY != H5Pget_driver(ret_fapl)) TEST_ERROR + + if(H5Gclose(group) < 0) TEST_ERROR + if(H5Fclose(file2) < 0) TEST_ERROR + if(H5Pclose(ret_fapl) < 0) TEST_ERROR + if(H5Pclose(fam_fapl) < 0) TEST_ERROR /* Modify the user data structure to cause the callback to fail next time */ op_data.code = 1; @@ -4250,7 +4250,7 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) H5E_BEGIN_TRY { group = H5Gopen2(file1, "/group1/ext_link/group2", gapl); } H5E_END_TRY; - if (group != FAIL) TEST_ERROR + if(group != FAIL) TEST_ERROR /* Modify the user data structure to cause the callback to return invalid flags */ op_data.code = 2; @@ -4259,11 +4259,11 @@ external_set_elink_cb(hid_t fapl, hbool_t new_format) H5E_BEGIN_TRY { group = H5Gopen2(file1, "/group1/ext_link/group2", gapl); } H5E_END_TRY; - if (group != FAIL) TEST_ERROR + if(group != FAIL) TEST_ERROR /* Close */ - if (H5Fclose(file1) < 0) TEST_ERROR - if (H5Pclose(gapl) < 0) TEST_ERROR + if(H5Fclose(file1) < 0) TEST_ERROR + if(H5Pclose(gapl) < 0) TEST_ERROR PASSED(); return 0; |