summaryrefslogtreecommitdiffstats
path: root/test/links.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/links.c')
-rw-r--r--test/links.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/test/links.c b/test/links.c
index 8612180..84d2542 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;