summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/cmpd_dset.c7
-rw-r--r--test/dsets.c94
-rw-r--r--test/external.c45
-rw-r--r--test/links.c156
-rwxr-xr-xtest/objcopy.c16
5 files changed, 180 insertions, 138 deletions
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index b154f51..d565e82 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -1998,9 +1998,10 @@ error:
static int
test_ooo_order(char *filename)
{
- hid_t file; /* File ID */
- hid_t dtype, dtype_tmp; /* Datatype IDs */
- H5T_t *dt; /* Datatype pointer */
+ hid_t file = -1; /* File ID */
+ hid_t dtype = -1; /* Datatype IDs */
+ hid_t dtype_tmp = -1; /* Temp Datatype ID */
+ H5T_t *dt = NULL; /* Datatype pointer */
TESTING("that compound member insertion order is preserved")
diff --git a/test/dsets.c b/test/dsets.c
index 0522bd0..58fa2c8 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -710,7 +710,9 @@ test_max_compact(hid_t fapl)
compact_size = (SIXTY_FOUR_KB-64)/sizeof(int);
wbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(wbuf);
rbuf = (int*)HDmalloc(sizeof(int)*(size_t)compact_size);
+ assert(rbuf);
n=0;
for(i=0; i<(int)compact_size; i++)
@@ -767,8 +769,9 @@ test_max_compact(hid_t fapl)
if(H5Dclose(dataset) < 0) goto error;
if(H5Fclose(file) < 0) goto error;
HDfree(wbuf);
+ wbuf = NULL;
HDfree(rbuf);
-
+ rbuf = NULL;
/* Test compact dataset of size 64KB */
@@ -802,6 +805,19 @@ test_max_compact(hid_t fapl)
return 0;
error:
+ if(wbuf)
+ HDfree(wbuf);
+ if(rbuf)
+ HDfree(rbuf);
+
+ H5E_BEGIN_TRY {
+ /* Close file */
+ H5Sclose(space);
+ H5Pclose(plist);
+ H5Fclose(file);
+ H5Dclose(dataset);
+ } H5E_END_TRY;
+
return -1;
}
@@ -973,10 +989,10 @@ error:
static herr_t
test_tconv(hid_t file)
{
- char *out=NULL, *in=NULL;
- int i;
+ char *out = NULL, *in = NULL;
hsize_t dims[1];
- hid_t space, dataset;
+ hid_t space = -1, dataset = -1;
+ int i;
out = (char *)HDmalloc((size_t)(4 * 1000 * 1000));
HDassert(out);
@@ -987,11 +1003,11 @@ test_tconv(hid_t file)
/* Initialize the dataset */
for(i = 0; i < 1000000; i++) {
- out[i*4+0] = 0x11;
- out[i*4+1] = 0x22;
- out[i*4+2] = 0x33;
- out[i*4+3] = 0x44;
- }
+ out[i * 4 + 0] = 0x11;
+ out[i * 4 + 1] = 0x22;
+ out[i * 4 + 2] = 0x33;
+ out[i * 4 + 3] = 0x44;
+ } /* end for */
/* Create the data space */
dims[0] = 1000000;
@@ -1008,27 +1024,39 @@ test_tconv(hid_t file)
/* Read data with byte order conversion */
if(H5Dread(dataset, H5T_STD_I32BE, H5S_ALL, H5S_ALL, H5P_DEFAULT, in) < 0)
- goto error;
+ goto error;
/* Check */
for(i = 0; i < 1000000; i++) {
- if(in[4*i+0]!=out[4*i+3] ||
- in[4*i+1]!=out[4*i+2] ||
- in[4*i+2]!=out[4*i+1] ||
- in[4*i+3]!=out[4*i+0]) {
- H5_FAILED();
- puts(" Read with byte order conversion failed.");
- goto error;
- }
+ if(in[4 * i + 0] != out[4 * i + 3] ||
+ in[4 * i + 1] != out[4 * i + 2] ||
+ in[4 * i + 2] != out[4 * i + 1] ||
+ in[4 * i + 3] != out[4 * i + 0]) {
+ H5_FAILED();
+ puts(" Read with byte order conversion failed.");
+ goto error;
+ }
}
if(H5Dclose(dataset) < 0) goto error;
- free (out);
- free (in);
+ if(H5Sclose(space) < 0) goto error;
+ HDfree(out);
+ HDfree(in);
+
puts(" PASSED");
return 0;
- error:
+error:
+ if(out)
+ HDfree(out);
+ if(in)
+ HDfree(in);
+
+ H5E_BEGIN_TRY {
+ H5Dclose(dataset);
+ H5Sclose(space);
+ } H5E_END_TRY;
+
return -1;
}
@@ -1241,19 +1269,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes,
size_t *buf_size, void **buf)
{
- size_t ret_value = 0;
+ void *data;
unsigned char *dst = (unsigned char*)(*buf);
unsigned int offset;
unsigned int length;
unsigned int value;
- void *data;
+ size_t ret_value = 0;
- if(cd_nelmts!=3 || !cd_values)
+ if(cd_nelmts != 3 || !cd_values)
return 0;
offset = cd_values[0];
length = cd_values[1];
value = cd_values[2];
- if(offset>nbytes || (offset+length)>nbytes || length<sizeof(unsigned int))
+ if(offset > nbytes || (offset + length) > nbytes || length < sizeof(unsigned int))
return 0;
data = HDmalloc((size_t)length);
@@ -1261,15 +1289,19 @@ filter_corrupt(unsigned int flags, size_t cd_nelmts,
if(flags & H5Z_FLAG_REVERSE) { /* Varify data is actually corrupted during read */
dst += offset;
- if(HDmemcmp(data, dst, (size_t)length)!=0) return 0;
- *buf_size = nbytes;
- ret_value = nbytes;
- } else { /* Write corrupted data */
+ if(HDmemcmp(data, dst, (size_t)length) != 0)
+ ret_value = 0;
+ else {
+ *buf_size = nbytes;
+ ret_value = nbytes;
+ } /* end else */
+ } /* end if */
+ else { /* Write corrupted data */
dst += offset;
HDmemcpy(dst, data, (size_t)length);
*buf_size = nbytes;
- ret_value = *buf_size;
- }
+ ret_value = *buf_size;
+ } /* end else */
if(data)
HDfree(data);
diff --git a/test/external.c b/test/external.c
index 25d465c..b3831ad 100644
--- a/test/external.c
+++ b/test/external.c
@@ -58,21 +58,23 @@ same_contents (const char *name1, const char *name2)
fd1 = HDopen(name1, O_RDONLY, 0666);
fd2 = HDopen(name2, O_RDONLY, 0666);
- assert (fd1>=0 && fd2>=0);
-
- while (1) {
- n1 = HDread(fd1, buf1, sizeof(buf1));
- n2 = HDread(fd2, buf2, sizeof(buf2));
- assert (n1>=0 && (size_t)n1<=sizeof(buf1));
- assert (n2>=0 && (size_t)n2<=sizeof(buf2));
- assert (n1==n2);
-
- if (n1<=0 && n2<=0) break;
- if (memcmp (buf1, buf2, (size_t)n1)) {
- HDclose(fd1);
- HDclose(fd2);
- return 0;
- }
+ assert(fd1 >= 0 && fd2 >= 0);
+
+ while(1) {
+ /* Asserts will catch negative return values */
+ n1 = HDread(fd1, buf1, sizeof(buf1));
+ n2 = HDread(fd2, buf2, sizeof(buf2));
+ assert(n1 >= 0 && (size_t)n1 <= sizeof(buf1));
+ assert(n2 >= 0 && (size_t)n2 <= sizeof(buf2));
+ assert(n1 == n2);
+
+ if(n1 == 0 && n2 == 0)
+ break;
+ if(HDmemcmp(buf1, buf2, (size_t)n1)) {
+ HDclose(fd1);
+ HDclose(fd2);
+ return 0;
+ }
}
HDclose(fd1);
HDclose(fd2);
@@ -838,10 +840,13 @@ test_3 (hid_t fapl)
static int
test_4 (hid_t fapl)
{
- hid_t fid, gid, xid, xid2;
- char filename[1024]; /*file name */
- char pathname[1024];
- char *srcdir = getenv("srcdir"); /*where the src code is located*/
+ hid_t fid = -1;
+ hid_t gid = -1;
+ hid_t xid = -1;
+ hid_t xid2 = -1;
+ char filename[1024]; /*file name */
+ char pathname[1024];
+ char *srcdir = getenv("srcdir"); /*where the src code is located*/
TESTING("opening external link twice");
@@ -911,7 +916,7 @@ test_4 (hid_t fapl)
H5Gclose(gid);
H5Gclose(xid);
H5Gclose(xid2);
- H5Fclose(fid);
+ H5Fclose(fid);
} H5E_END_TRY;
return 1;
}
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;
diff --git a/test/objcopy.c b/test/objcopy.c
index 50dabcc..00cc5bf 100755
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -713,7 +713,9 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
/* Release raw data buffers */
HDfree(rbuf);
+ rbuf = NULL;
HDfree(rbuf2);
+ rbuf2 = NULL;
/* close the source dataspace */
if(H5Sclose(sid) < 0) TEST_ERROR
@@ -730,11 +732,11 @@ compare_attribute(hid_t aid, hid_t aid2, hid_t pid, const void *wbuf, hid_t obj_
return TRUE;
error:
+ if(rbuf)
+ HDfree(rbuf);
+ if(rbuf2)
+ HDfree(rbuf2);
H5E_BEGIN_TRY {
- if(rbuf)
- HDfree(rbuf);
- if(rbuf2)
- HDfree(rbuf2);
H5Sclose(sid2);
H5Sclose(sid);
H5Tclose(tid2);
@@ -7247,9 +7249,11 @@ static int
test_copy_dataset_contig_cmpd_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t fapl)
{
hid_t fid_src = -1, fid_dst = -1; /* File IDs */
- hid_t tid = -1, tid2; /* Datatype IDs */
+ hid_t tid = -1; /* Datatype ID */
+ hid_t tid2 = -1; /* Datatype ID */
hid_t sid = -1; /* Dataspace ID */
- hid_t did = -1, did2 = -1; /* Dataset IDs */
+ hid_t did = -1; /* Dataset ID */
+ hid_t did2 = -1; /* Dataset ID */
unsigned int i, j; /* Local index variables */
hsize_t dim1d[1]; /* Dataset dimensions */
cmpd_vl_t buf[DIM_SIZE_1]; /* Buffer for writing data */