summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorjhendersonHDF <jhenderson@hdfgroup.org>2021-06-16 20:45:26 (GMT)
committerGitHub <noreply@github.com>2021-06-16 20:45:26 (GMT)
commitbb7dfbebdcaf3a838d03167a309b9934b997ce92 (patch)
treeabd9e0690ace1a47cc8c6a7e73c49281d38483c3 /test
parente4e9bb70db3ee275977caad4b494021af41619d7 (diff)
downloadhdf5-bb7dfbebdcaf3a838d03167a309b9934b997ce92.zip
hdf5-bb7dfbebdcaf3a838d03167a309b9934b997ce92.tar.gz
hdf5-bb7dfbebdcaf3a838d03167a309b9934b997ce92.tar.bz2
Fix several warnings (#747)
Diffstat (limited to 'test')
-rw-r--r--test/cache_common.c2
-rw-r--r--test/chunk_info.c7
-rw-r--r--test/cmpd_dset.c4
-rw-r--r--test/cross_read.c2
-rw-r--r--test/direct_chunk.c6
-rw-r--r--test/dsets.c42
-rw-r--r--test/dtypes.c56
-rw-r--r--test/file_image.c14
-rw-r--r--test/genall5.c20
-rw-r--r--test/h5test.c10
-rw-r--r--test/objcopy.c12
-rw-r--r--test/trefer_deprec.c6
-rw-r--r--test/use_common.c21
13 files changed, 152 insertions, 50 deletions
diff --git a/test/cache_common.c b/test/cache_common.c
index e86724f..0ddcbb8 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -4492,7 +4492,7 @@ col_major_scan_backward(H5F_t *file_ptr, int32_t max_index, int32_t lag, hbool_t
int mile_stone = 1;
int32_t type;
int32_t idx;
- int32_t local_max_index[NUMBER_OF_ENTRY_TYPES];
+ int32_t local_max_index[NUMBER_OF_ENTRY_TYPES] = {0};
if (verbose)
HDfprintf(stdout, "%s: entering.\n", FUNC);
diff --git a/test/chunk_info.c b/test/chunk_info.c
index 7440459..a1c4160 100644
--- a/test/chunk_info.c
+++ b/test/chunk_info.c
@@ -482,10 +482,10 @@ test_get_chunk_info_highest_v18(hid_t fapl)
unsigned flt_msk = 0; /* Filter mask */
unsigned read_flt_msk = 0; /* Filter mask after direct read */
int fillvalue = -1; /* Fill value */
- int aggression = 9; /* Compression aggression setting */
hsize_t offset[2] = {0, 0}; /* Offset coordinates of a chunk */
#ifdef H5_HAVE_FILTER_DEFLATE
- const Bytef *z_src = (const Bytef *)(direct_buf);
+ int aggression = 9; /* Compression aggression setting */
+ const Bytef *z_src = (const Bytef *)(direct_buf);
Bytef * z_dst; /* Destination buffer */
uLongf z_dst_nbytes = (uLongf)DEFLATE_SIZE_ADJUST(CHK_SIZE);
uLong z_src_nbytes = (uLong)CHK_SIZE;
@@ -568,7 +568,8 @@ test_get_chunk_info_highest_v18(hid_t fapl)
}
#else
/* Allocate input (non-compressed) buffer */
- inbuf = HDcalloc(1, CHK_SIZE);
+ if (NULL == (inbuf = HDcalloc(1, CHK_SIZE)))
+ TEST_ERROR
HDmemcpy(inbuf, direct_buf, CHK_SIZE);
#endif /* end H5_HAVE_FILTER_DEFLATE */
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index e74b438..4c3233d 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -1466,6 +1466,10 @@ test_hdf5_src_subset(char *filename, hid_t fapl)
return 0;
error:
+ HDfree(orig);
+ HDfree(rbuf);
+ HDfree(rew_buf);
+
HDputs("*** DATASET TESTS FAILED ***");
return 1;
}
diff --git a/test/cross_read.c b/test/cross_read.c
index eef814f..cb71996 100644
--- a/test/cross_read.c
+++ b/test/cross_read.c
@@ -41,8 +41,10 @@ const char *FILENAME[] = {"vms_data", "le_data", "be_data", NULL};
#define DATASETNAME14 "Fletcher_float_data_le"
#define DATASETNAME15 "Fletcher_float_data_be"
+#ifdef H5_HAVE_FILTER_DEFLATE
#define DATASETNAME16 "Deflate_float_data_le"
#define DATASETNAME17 "Deflate_float_data_be"
+#endif
#ifdef H5_HAVE_FILTER_SZIP
#define DATASETNAME18 "Szip_float_data_le"
#define DATASETNAME19 "Szip_float_data_be"
diff --git a/test/direct_chunk.c b/test/direct_chunk.c
index 0d270bd..8960784 100644
--- a/test/direct_chunk.c
+++ b/test/direct_chunk.c
@@ -23,7 +23,9 @@
#define FILE_NAME "direct_chunk.h5"
/* Datasets for Direct Write tests */
+#ifdef H5_HAVE_FILTER_DEFLATE
#define DATASETNAME1 "direct_write"
+#endif
#define DATASETNAME2 "skip_one_filter"
#define DATASETNAME3 "skip_two_filters"
#define DATASETNAME4 "data_conv"
@@ -31,9 +33,11 @@
#define DATASETNAME6 "invalid_argue"
#define DATASETNAME7 "overwrite_chunk"
/* Datasets for Direct Read tests */
+#ifdef H5_HAVE_FILTER_DEFLATE
#define DATASETNAME8 "disabled_chunk_cache"
#define DATASETNAME9 "flush_chunk_cache"
#define DATASETNAME10 "read_w_valid_cache"
+#endif
#define DATASETNAME11 "unallocated_chunk"
#define DATASETNAME12 "unfiltered_data"
@@ -43,7 +47,9 @@
#define CHUNK_NX 4
#define CHUNK_NY 4
+#ifdef H5_HAVE_FILTER_DEFLATE
#define DEFLATE_SIZE_ADJUST(s) (HDceil(((double)(s)) * 1.001) + 12.0)
+#endif
/* Temporary filter IDs used for testing */
#define H5Z_FILTER_BOGUS1 305
diff --git a/test/dsets.c b/test/dsets.c
index cc35fe3..26322ad 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -95,25 +95,29 @@ const char *FILENAME[] = {"dataset", /* 0 */
#define FILE_DEFLATE_NAME "deflate.h5"
/* Dataset names for testing filters */
-#define DSET_DEFAULT_NAME "default"
-#define DSET_CHUNKED_NAME "chunked"
-#define DSET_COMPACT_NAME "compact"
-#define DSET_SIMPLE_IO_NAME "simple_io"
-#define DSET_USERBLOCK_IO_NAME "userblock_io"
-#define DSET_COMPACT_IO_NAME "compact_io"
-#define DSET_COMPACT_MAX_NAME "max_compact"
-#define DSET_COMPACT_MAX2_NAME "max_compact_2"
-#define DSET_CONV_BUF_NAME "conv_buf"
-#define DSET_TCONV_NAME "tconv"
-#define DSET_DEFLATE_NAME "deflate"
-#define DSET_SHUFFLE_NAME "shuffle"
-#define DSET_FLETCHER32_NAME "fletcher32"
-#define DSET_FLETCHER32_NAME_2 "fletcher32_2"
-#define DSET_FLETCHER32_NAME_3 "fletcher32_3"
+#define DSET_DEFAULT_NAME "default"
+#define DSET_CHUNKED_NAME "chunked"
+#define DSET_COMPACT_NAME "compact"
+#define DSET_SIMPLE_IO_NAME "simple_io"
+#define DSET_USERBLOCK_IO_NAME "userblock_io"
+#define DSET_COMPACT_IO_NAME "compact_io"
+#define DSET_COMPACT_MAX_NAME "max_compact"
+#define DSET_COMPACT_MAX2_NAME "max_compact_2"
+#define DSET_CONV_BUF_NAME "conv_buf"
+#define DSET_TCONV_NAME "tconv"
+#ifdef H5_HAVE_FILTER_DEFLATE
+#define DSET_DEFLATE_NAME "deflate"
+#endif
+#define DSET_SHUFFLE_NAME "shuffle"
+#define DSET_FLETCHER32_NAME "fletcher32"
+#define DSET_FLETCHER32_NAME_2 "fletcher32_2"
+#define DSET_FLETCHER32_NAME_3 "fletcher32_3"
+#ifdef H5_HAVE_FILTER_DEFLATE
#define DSET_SHUF_DEF_FLET_NAME "shuffle+deflate+fletcher32"
#define DSET_SHUF_DEF_FLET_NAME_2 "shuffle+deflate+fletcher32_2"
-#define DSET_OPTIONAL_SCALAR "dataset_with_scalar_space"
-#define DSET_OPTIONAL_VLEN "dataset_with_vlen_type"
+#endif
+#define DSET_OPTIONAL_SCALAR "dataset_with_scalar_space"
+#define DSET_OPTIONAL_VLEN "dataset_with_vlen_type"
#ifdef H5_HAVE_FILTER_SZIP
#define DSET_SZIP_NAME "szip"
#define DSET_SHUF_SZIP_FLET_NAME "shuffle+szip+fletcher32"
@@ -1504,6 +1508,9 @@ test_conv_buffer(hid_t fid)
return SUCCEED;
error:
+ HDfree(cfrR);
+ HDfree(cf);
+
H5E_BEGIN_TRY
{
H5Pclose(xfer_list);
@@ -7162,6 +7169,7 @@ error:
H5E_END_TRY;
return FAIL;
#else
+ (void)file; /* Silence compiler */
SKIPPED();
return SUCCEED;
#endif
diff --git a/test/dtypes.c b/test/dtypes.c
index 52eb0ea..2a18302 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -783,9 +783,12 @@ test_compound_2(void)
FAIL_STACK_ERROR
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st));
+ if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)))))
+ goto error;
+ if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt))))
+ goto error;
+ if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st))))
+ goto error;
for (i = 0; i < (int)nelmts; i++) {
s_ptr = ((struct st *)((void *)orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -857,6 +860,10 @@ test_compound_2(void)
return 0;
error:
+ HDfree(buf);
+ HDfree(bkg);
+ HDfree(orig);
+
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@@ -903,9 +910,12 @@ test_compound_3(void)
FAIL_STACK_ERROR
/* Initialize */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st));
+ if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)))))
+ goto error;
+ if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt))))
+ goto error;
+ if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st))))
+ goto error;
for (i = 0; i < (int)nelmts; i++) {
s_ptr = ((struct st *)((void *)orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -973,6 +983,10 @@ test_compound_3(void)
return 0;
error:
+ HDfree(buf);
+ HDfree(bkg);
+ HDfree(orig);
+
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@@ -1023,9 +1037,12 @@ test_compound_4(void)
FAIL_STACK_ERROR
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st));
+ if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)))))
+ goto error;
+ if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt))))
+ goto error;
+ if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st))))
+ goto error;
for (i = 0; i < (int)nelmts; i++) {
s_ptr = ((struct st *)((void *)orig)) + i;
s_ptr->a = i * 8 + 0;
@@ -1096,6 +1113,10 @@ test_compound_4(void)
return 0;
error:
+ HDfree(buf);
+ HDfree(bkg);
+ HDfree(orig);
+
/* Restore the default error handler (set in h5_reset()) */
h5_restore_err();
@@ -1146,6 +1167,12 @@ test_compound_5(void)
TESTING("optimized struct converter");
+ if (!buf || !bkg) {
+ HDfree(buf);
+ HDfree(bkg);
+ return 1;
+ }
+
/* Build datatypes */
short_array = H5Tcreate(H5T_COMPOUND, 4 * sizeof(short));
array_dt = H5Tarray_create2(H5T_NATIVE_SHORT, 1, dims);
@@ -1238,9 +1265,12 @@ test_compound_6(void)
FAIL_STACK_ERROR
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st));
+ if (NULL == (buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(struct st), sizeof(struct dt)))))
+ goto error;
+ if (NULL == (bkg = (unsigned char *)HDmalloc(nelmts * sizeof(struct dt))))
+ goto error;
+ if (NULL == (orig = (unsigned char *)HDmalloc(nelmts * sizeof(struct st))))
+ goto error;
for (i = 0; i < (int)nelmts; i++) {
s_ptr = ((struct st *)((void *)orig)) + i;
s_ptr->b = (int16_t)((i * 8 + 1) & 0x7fff);
@@ -2290,6 +2320,8 @@ test_compound_11(void)
((big_t *)buf)[u].i1 = (int)(u * 3);
((big_t *)buf)[u].i2 = (int)(u * 5);
((big_t *)buf)[u].s1 = (char *)HDmalloc((size_t)32);
+ if (!((big_t *)buf)[u].s1)
+ TEST_ERROR
HDsprintf(((big_t *)buf)[u].s1, "%u", (unsigned)u);
} /* end for */
diff --git a/test/file_image.c b/test/file_image.c
index f6075d5..0373468 100644
--- a/test/file_image.c
+++ b/test/file_image.c
@@ -102,8 +102,9 @@ test_properties(void)
* property list functions. In the file driver tests further down, this will
* not be the case.
*/
- size = (size_t)count * sizeof(char);
- buffer = (char *)HDmalloc(size);
+ size = (size_t)count * sizeof(char);
+ if (NULL == (buffer = (char *)HDmalloc(size)))
+ TEST_ERROR
for (i = 0; i < count - 1; i++)
buffer[i] = (char)(65 + i);
buffer[count - 1] = '\0';
@@ -338,8 +339,8 @@ test_callbacks(void)
H5FD_file_image_callbacks_t callbacks;
hid_t fapl_1;
hid_t fapl_2;
- udata_t * udata;
- char * file_image;
+ udata_t * udata = NULL;
+ char * file_image = NULL;
char * temp_file_image;
int count = 10;
int i;
@@ -350,6 +351,7 @@ test_callbacks(void)
/* Allocate and initialize udata */
udata = (udata_t *)HDmalloc(sizeof(udata_t));
+ VERIFY(udata != NULL, "udata malloc failed");
reset_udata(udata);
/* copy the address of the user data into read_callbacks */
@@ -358,6 +360,7 @@ test_callbacks(void)
/* Allocate and initialize file image buffer */
size = (size_t)count * sizeof(char);
file_image = (char *)HDmalloc(size);
+ VERIFY(file_image != NULL, "file_image malloc failed");
for (i = 0; i < count - 1; i++)
file_image[i] = (char)(65 + i);
file_image[count - 1] = '\0';
@@ -529,6 +532,9 @@ test_callbacks(void)
return 0;
error:
+ HDfree(file_image);
+ HDfree(udata);
+
return 1;
} /* test_callbacks() */
diff --git a/test/genall5.c b/test/genall5.c
index a6331f6..1da61f8 100644
--- a/test/genall5.c
+++ b/test/genall5.c
@@ -1673,10 +1673,10 @@ ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data)
failure_mssg = "ds_ctg_i: H5Dwrite() failed.";
}
HDassert(ret >= 0);
-
- HDfree(wdata);
}
+ HDfree(wdata);
+
if (pass) {
ret = H5Dclose(dsid);
@@ -1891,10 +1891,10 @@ vrfy_ds_ctg_i(hid_t fid, const char *dset_name, hbool_t write_data)
}
HDassert((int)u == rdata[u]);
}
-
- HDfree(rdata);
} /* end if */
+ HDfree(rdata);
+
if (pass) {
ret = H5Dclose(dsid);
@@ -2250,10 +2250,10 @@ vrfy_ds_chk_i(hid_t fid, const char *dset_name, hbool_t write_data)
}
HDassert((int)u == rdata[u]);
}
-
- HDfree(rdata);
} /* end if */
+ HDfree(rdata);
+
if (pass) {
ret = H5Dclose(dsid);
@@ -2590,10 +2590,10 @@ vrfy_ds_cpt_i(hid_t fid, const char *dset_name, hbool_t write_data)
}
HDassert((int)u == rdata[u]);
}
-
- HDfree(rdata);
} /* end if */
+ HDfree(rdata);
+
if (pass) {
ret = H5Dclose(dsid);
@@ -2982,10 +2982,10 @@ vrfy_ds_ctg_v(hid_t fid, const char *dset_name, hbool_t write_data)
failure_mssg = "vrfy_ds_ctg_v: H5Treclaim() failed.";
}
HDassert(ret >= 0);
-
- HDfree(rdata);
} /* end if */
+ HDfree(rdata);
+
if (pass) {
ret = H5Sclose(sid);
diff --git a/test/h5test.c b/test/h5test.c
index 2a54982..4dff00d 100644
--- a/test/h5test.c
+++ b/test/h5test.c
@@ -1195,9 +1195,10 @@ h5_set_info_object(void)
valp++;
/* copy key/value pair into temporary buffer */
- len = strcspn(valp, ";");
- next = &valp[len];
- key_val = (char *)HDcalloc(1, len + 1);
+ len = strcspn(valp, ";");
+ next = &valp[len];
+ if (NULL == (key_val = (char *)HDcalloc(1, len + 1)))
+ return -1;
/* increment the next pointer past the terminating semicolon */
if (*next == ';')
@@ -1593,6 +1594,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name)
void * buf = NULL; /* Buffer for copying data */
const char *filename = H5_get_srcdir_filename(origfilename); /* Get the test file name to copy */
+ if (!filename)
+ goto error;
+
/* Allocate copy buffer */
if (NULL == (buf = HDcalloc((size_t)1, (size_t)READ_BUF_SIZE)))
goto error;
diff --git a/test/objcopy.c b/test/objcopy.c
index 43a5756..e01083d 100644
--- a/test/objcopy.c
+++ b/test/objcopy.c
@@ -4498,6 +4498,10 @@ test_copy_dataset_compressed(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, hid
TESTING("H5Ocopy(): compressed dataset");
#ifndef H5_HAVE_FILTER_DEFLATE
+ (void)fcpl_src;
+ (void)fcpl_dst;
+ (void)src_fapl;
+ (void)dst_fapl; /* Silence compiler */
SKIPPED();
HDputs(" Deflation filter not available");
#else /* H5_HAVE_FILTER_DEFLATE */
@@ -4923,6 +4927,10 @@ test_copy_dataset_no_edge_filt(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl, h
}
#ifndef H5_HAVE_FILTER_DEFLATE
+ (void)fcpl_src;
+ (void)fcpl_dst;
+ (void)src_fapl;
+ (void)dst_fapl; /* Silence compiler */
SKIPPED();
HDputs(" Deflation filter not available");
#else /* H5_HAVE_FILTER_DEFLATE */
@@ -7277,6 +7285,10 @@ test_copy_dataset_compressed_vl(hid_t fcpl_src, hid_t fcpl_dst, hid_t src_fapl,
TESTING("H5Ocopy(): compressed dataset with VLEN datatype");
#ifndef H5_HAVE_FILTER_DEFLATE
+ (void)fcpl_src;
+ (void)fcpl_dst;
+ (void)src_fapl;
+ (void)dst_fapl; /* Silence compiler */
SKIPPED();
HDputs(" Deflation filter not available");
#else /* H5_HAVE_FILTER_DEFLATE */
diff --git a/test/trefer_deprec.c b/test/trefer_deprec.c
index 24371ef..755df68 100644
--- a/test/trefer_deprec.c
+++ b/test/trefer_deprec.c
@@ -87,8 +87,11 @@ test_reference_params(void)
/* Allocate write & read buffers */
wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(wbuf, "HDmalloc");
rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(rbuf, "HDmalloc");
tbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(tbuf, "HDmalloc");
/* Create file */
fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
@@ -269,8 +272,11 @@ test_reference_obj(void)
/* Allocate write & read buffers */
wbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(wbuf, "HDmalloc");
rbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(rbuf, "HDmalloc");
tbuf = (hobj_ref_t *)HDmalloc(MAX(sizeof(unsigned), sizeof(hobj_ref_t)) * SPACE1_DIM1);
+ CHECK_PTR(tbuf, "HDmalloc");
/* Create file */
fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
diff --git a/test/use_common.c b/test/use_common.c
index 0ea2c83..8f78f3b 100644
--- a/test/use_common.c
+++ b/test/use_common.c
@@ -322,10 +322,12 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
rank = H5Sget_simple_extent_ndims(f_sid);
if (rank != UC_RANK) {
HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+ HDfree(buffer);
return -1;
}
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]),
@@ -334,12 +336,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (dims[0] != 0 || dims[1] != memdims[1] || dims[2] != memdims[2]) {
HDfprintf(stderr, "dataset is not empty. Got dims=(%llu,%llu,%llu)\n", (unsigned long long)dims[0],
(unsigned long long)dims[1], (unsigned long long)dims[2]);
+ HDfree(buffer);
return -1;
}
/* setup mem-space for buffer */
if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) {
HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+ HDfree(buffer);
return -1;
}
@@ -360,6 +364,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (opts->use_swmr) {
if (H5Odisable_mdc_flushes(dsid) < 0) {
HDfprintf(stderr, "H5Odisable_mdc_flushes failed\n");
+ HDfree(buffer);
return -1;
}
}
@@ -368,12 +373,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
dims[0] = i + 1;
if (H5Dset_extent(dsid, dims) < 0) {
HDfprintf(stderr, "H5Dset_extent failed\n");
+ HDfree(buffer);
return -1;
}
/* Get the dataset's dataspace */
if ((f_sid = H5Dget_space(dsid)) < 0) {
HDfprintf(stderr, "H5Dset_extent failed\n");
+ HDfree(buffer);
return -1;
}
@@ -381,12 +388,14 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
/* Choose the next plane to write */
if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) {
HDfprintf(stderr, "Failed H5Sselect_hyperslab\n");
+ HDfree(buffer);
return -1;
}
/* Write plane to the dataset */
if (H5Dwrite(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) {
HDfprintf(stderr, "Failed H5Dwrite\n");
+ HDfree(buffer);
return -1;
}
@@ -394,6 +403,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
if (opts->use_swmr) {
if (H5Oenable_mdc_flushes(dsid) < 0) {
HDfprintf(stderr, "H5Oenable_mdc_flushes failed\n");
+ HDfree(buffer);
return -1;
}
}
@@ -401,6 +411,7 @@ write_uc_file(hbool_t tosend, hid_t file_id, options_t *opts)
/* flush file to make the just written plane available. */
if (H5Dflush(dsid) < 0) {
HDfprintf(stderr, "Failed to H5Fflush file\n");
+ HDfree(buffer);
return -1;
}
} /* end for each plane to write */
@@ -488,10 +499,12 @@ read_uc_file(hbool_t towait, options_t *opts)
rank = H5Sget_simple_extent_ndims(f_sid);
if (rank != UC_RANK) {
HDfprintf(stderr, "rank(%d) of dataset does not match\n", rank);
+ HDfree(buffer);
return -1;
}
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
HDprintf("dataset rank %d, dimensions %llu x %llu x %llu\n", rank, (unsigned long long)(dims[0]),
@@ -502,12 +515,14 @@ read_uc_file(hbool_t towait, options_t *opts)
(unsigned long long)dims[0], (unsigned long long)dims[1], (unsigned long long)dims[2]);
HDfprintf(stderr, "But memdims=(%llu,%llu,%llu)\n", (unsigned long long)memdims[0],
(unsigned long long)memdims[1], (unsigned long long)memdims[2]);
+ HDfree(buffer);
return -1;
}
/* Setup mem-space for buffer */
if ((m_sid = H5Screate_simple(rank, memdims, NULL)) < 0) {
HDfprintf(stderr, "H5Screate_simple for memory failed\n");
+ HDfree(buffer);
return -1;
}
@@ -533,6 +548,7 @@ read_uc_file(hbool_t towait, options_t *opts)
HDprintf(".");
if (loops_waiting_for_plane >= 30) {
HDfprintf(stderr, "waited too long for new plane, quit.\n");
+ HDfree(buffer);
return -1;
}
}
@@ -550,6 +566,7 @@ read_uc_file(hbool_t towait, options_t *opts)
/* Get the dataset's dataspace */
if ((f_sid = H5Dget_space(dsid)) < 0) {
HDfprintf(stderr, "H5Dget_space failed\n");
+ HDfree(buffer);
return -1;
}
@@ -557,12 +574,14 @@ read_uc_file(hbool_t towait, options_t *opts)
/* Choose the next plane to read */
if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, count, NULL) < 0) {
HDfprintf(stderr, "H5Sselect_hyperslab failed\n");
+ HDfree(buffer);
return -1;
}
/* Read the plane from the dataset */
if (H5Dread(dsid, UC_DATATYPE, m_sid, f_sid, H5P_DEFAULT, buffer) < 0) {
HDfprintf(stderr, "H5Dread failed\n");
+ HDfree(buffer);
return -1;
}
@@ -594,12 +613,14 @@ read_uc_file(hbool_t towait, options_t *opts)
f_sid = H5Dget_space(dsid); /* Get filespace handle first. */
if (H5Sget_simple_extent_dims(f_sid, dims, NULL) < 0) {
HDfprintf(stderr, "H5Sget_simple_extent_dims got error\n");
+ HDfree(buffer);
return -1;
}
} /* end while (expecting more planes to read) */
if (H5Fclose(fid) < 0) {
HDfprintf(stderr, "H5Fclose failed\n");
+ HDfree(buffer);
return -1;
}