From b1eb1b3ee8693e2a56b074315b521c66255acca1 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 1 Sep 2016 17:24:24 -0500 Subject: Replace assertion in H5O_dtype_decode_helper for number of array dimensions with a check and error. The assertion was inappropriate because it is operating on data read from the file, which the library does not always have direct control of. --- src/H5Odtype.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index e51d319..eae542b 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -519,7 +519,8 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p dt->shared->u.array.ndims = *(*pp)++; /* Double-check the number of dimensions */ - HDassert(dt->shared->u.array.ndims <= H5S_MAX_RANK); + if(dt->shared->u.array.ndims > H5S_MAX_RANK) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "too many dimensions for array datatype") /* Skip reserved bytes, if version has them */ if(version < H5O_DTYPE_VERSION_3) -- cgit v0.12 From 2409f991667283f8fa1dacc66f245950693495aa Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 8 Sep 2016 10:48:54 -0500 Subject: Fix issues in H5Znbit.c where the decompression algorithm would not check the compressed data for validity, potentially causing a buffer overflow. --- src/H5Znbit.c | 97 ++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 73 insertions(+), 24 deletions(-) diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 04e8869..7efab42 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -65,13 +65,13 @@ static void H5Z_nbit_decompress_one_nooptype(unsigned char *data, size_t data_of unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); static void H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const parms_atomic *p); -static void H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, +static herr_t H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index); -static void H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, +static herr_t H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index); -static void H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static herr_t H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]); static void H5Z_nbit_compress_one_nooptype(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, unsigned size); @@ -1011,7 +1011,8 @@ H5Z_filter_nbit(unsigned flags, size_t cd_nelmts, const unsigned cd_values[], HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed for nbit decompression") /* decompress the buffer */ - H5Z_nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values); + if(H5Z__nbit_decompress(outbuf, d_nelmts, (unsigned char *)*buf, cd_values) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, 0, "can't decompress buffer") } /* end if */ /* output; compress */ else { @@ -1166,13 +1167,16 @@ H5Z_nbit_decompress_one_atomic(unsigned char *data, size_t data_offset, } } -static void -H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, +static herr_t +H5Z__nbit_decompress_one_array(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index) { unsigned i, total_size, base_class, base_size, n, begin_index; parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC total_size = parms[(*parms_index)++]; base_class = parms[(*parms_index)++]; @@ -1183,6 +1187,11 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, p.order = parms[(*parms_index)++]; p.precision = parms[(*parms_index)++]; p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + n = total_size / p.size; for(i = 0; i < n; i++) H5Z_nbit_decompress_one_atomic(data, data_offset + i * p.size, @@ -1194,8 +1203,9 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, n = total_size / base_size; /* number of base_type elements inside the array datatype */ begin_index = *parms_index; for(i = 0; i < n; i++) { - H5Z_nbit_decompress_one_array(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_array(data, data_offset + i * base_size, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") *parms_index = begin_index; } break; @@ -1205,8 +1215,9 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, n = total_size / base_size; /* number of base_type elements inside the array datatype */ begin_index = *parms_index; for(i = 0; i < n; i++) { - H5Z_nbit_decompress_one_compound(data, data_offset + i * base_size, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_compound(data, data_offset + i * base_size, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") *parms_index = begin_index; } break; @@ -1219,44 +1230,66 @@ H5Z_nbit_decompress_one_array(unsigned char *data, size_t data_offset, default: HDassert(0 && "This Should never be executed!"); } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } -static void -H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, +static herr_t +H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, unsigned char *buffer, size_t *j, size_t *buf_len, const unsigned parms[], unsigned *parms_index) { - unsigned i, nmembers, member_offset, member_class, size; + unsigned i, nmembers, member_offset, member_class, member_size, used_size = 0, size; parms_atomic p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC - (*parms_index)++; /* skip total size of compound datatype */ + size = parms[(*parms_index)++]; nmembers = parms[(*parms_index)++]; for(i = 0; i < nmembers; i++) { member_offset = parms[(*parms_index)++]; member_class = parms[(*parms_index)++]; + + /* Check for overflow */ + member_size = parms[*parms_index]; + used_size += member_size; + if(used_size > size) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "compound member offset overflowed compound size") switch(member_class) { case H5Z_NBIT_ATOMIC: - p.size = parms[(*parms_index)++]; + p.size = member_size; + /* Advance past member size */ + (*parms_index)++; p.order = parms[(*parms_index)++]; p.precision = parms[(*parms_index)++]; p.offset = parms[(*parms_index)++]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + H5Z_nbit_decompress_one_atomic(data, data_offset + member_offset, buffer, j, buf_len, &p); break; case H5Z_NBIT_ARRAY: - H5Z_nbit_decompress_one_array(data, data_offset + member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_array(data, data_offset + member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") break; case H5Z_NBIT_COMPOUND: - H5Z_nbit_decompress_one_compound(data, data_offset+member_offset, - buffer, j, buf_len, parms, parms_index); + if(H5Z__nbit_decompress_one_compound(data, data_offset+member_offset, + buffer, j, buf_len, parms, parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") break; case H5Z_NBIT_NOOPTYPE: - size = parms[(*parms_index)++]; + /* Advance past member size */ + (*parms_index)++; H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, buffer, j, buf_len, size); break; @@ -1265,10 +1298,13 @@ H5Z_nbit_decompress_one_compound(unsigned char *data, size_t data_offset, HDassert(0 && "This Should never be executed!"); } /* end switch */ } + +done: + FUNC_LEAVE_NOAPI(ret_value) } -static void -H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, +static herr_t +H5Z__nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffer, const unsigned parms[]) { /* i: index of data, j: index of buffer, @@ -1278,6 +1314,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size_t buf_len; parms_atomic p; unsigned parms_index; /* index in array parms used by compression/decompression functions */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC /* may not have to initialize to zeros */ HDmemset(data, 0, d_nelmts * parms[4]); @@ -1292,6 +1331,11 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe p.order = parms[5]; p.precision = parms[6]; p.offset = parms[7]; + + /* Check values of precision and offset */ + if(p.precision > p.size * 8 || (p.precision + p.offset) > p.size * 8) + HGOTO_ERROR(H5E_PLINE, H5E_BADTYPE, FAIL, "invalid datatype precision/offset") + for(i = 0; i < d_nelmts; i++) H5Z_nbit_decompress_one_atomic(data, i * p.size, buffer, &j, &buf_len, &p); break; @@ -1300,7 +1344,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_array(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress array") parms_index = 4; } break; @@ -1309,7 +1354,8 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe size = parms[4]; parms_index = 4; /* set the index before goto function call */ for(i = 0; i < d_nelmts; i++) { - H5Z_nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index); + if(H5Z__nbit_decompress_one_compound(data, i * size, buffer, &j, &buf_len, parms, &parms_index) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTFILTER, FAIL, "can't decompress compound") parms_index = 4; } break; @@ -1317,6 +1363,9 @@ H5Z_nbit_decompress(unsigned char *data, unsigned d_nelmts, unsigned char *buffe default: HDassert(0 && "This Should never be executed!"); } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) } static void -- cgit v0.12 From bc10fd219e60fc4b9df7d80567ecb1e39ae5b6e3 Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Thu, 8 Sep 2016 13:47:22 -0500 Subject: Change check for number of dimensions for old-style arrays in datatype decoding routine from an assertion to an if/HGOTO_ERROR check, since it is inappropriate to assert the contents of a file will be what we expect. --- src/H5Odtype.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/H5Odtype.c b/src/H5Odtype.c index e51d319..3c3f284 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -311,7 +311,11 @@ H5O_dtype_decode_helper(H5F_t *f, unsigned *ioflags/*in,out*/, const uint8_t **p if(version == H5O_DTYPE_VERSION_1) { /* Decode the number of dimensions */ ndims = *(*pp)++; - HDassert(ndims <= 4); + + /* Check that ndims is valid */ + if(ndims > 4) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "invalid number of dimensions for array") + *pp += 3; /*reserved bytes */ /* Skip dimension permutation */ -- cgit v0.12 From 391a231b76c1200ecda5d74636213e9e479fa51a Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Fri, 9 Sep 2016 12:08:30 -0500 Subject: Fix bug in "nooptype" decode in fix for TALOS-0177. --- src/H5Znbit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5Znbit.c b/src/H5Znbit.c index 7efab42..7a41d16 100644 --- a/src/H5Znbit.c +++ b/src/H5Znbit.c @@ -1291,7 +1291,7 @@ H5Z__nbit_decompress_one_compound(unsigned char *data, size_t data_offset, /* Advance past member size */ (*parms_index)++; H5Z_nbit_decompress_one_nooptype(data, data_offset+member_offset, - buffer, j, buf_len, size); + buffer, j, buf_len, member_size); break; default: -- cgit v0.12 From ef2e93d23988b44c663b6df583edecd2e604f009 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 19 Sep 2016 14:04:40 -0500 Subject: Eliminate unreferenced local variable warning --- java/src/jni/h5pImp.c | 12 ------------ java/src/jni/h5util.c | 18 +----------------- 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/java/src/jni/h5pImp.c b/java/src/jni/h5pImp.c index ad79733..7c71da1 100644 --- a/java/src/jni/h5pImp.c +++ b/java/src/jni/h5pImp.c @@ -4947,7 +4947,6 @@ H5P_cls_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR create_callback); @@ -4972,7 +4971,6 @@ H5P_cls_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR copy_callback); @@ -4995,7 +4993,6 @@ H5P_cls_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR close_callback); @@ -5019,7 +5016,6 @@ H5D_append_cb jclass cls; jmethodID mid; jlongArray cur_dimsArray; - jsize size; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { JVMPTR->DetachCurrentThread(JVMPAR); @@ -5135,7 +5131,6 @@ H5P_prp_create_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5160,7 +5155,6 @@ H5P_prp_copy_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5185,7 +5179,6 @@ H5P_prp_close_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5210,7 +5203,6 @@ H5P_prp_compare_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { cls = CBENVPTR->GetObjectClass(CBENVPAR compare_callback); @@ -5233,7 +5225,6 @@ H5P_prp_get_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5258,7 +5249,6 @@ H5P_prp_set_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5283,7 +5273,6 @@ H5P_prp_delete_cb jint status = -1; jclass cls; jmethodID mid; - jmethodID constructor; jstring str; if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) == 0) { @@ -5472,7 +5461,6 @@ H5P_iterate_cb jclass cls; jmethodID mid; jstring str; - jmethodID constructor; /* fprintf(stderr, "\nJNI H5P_iterate_cb entered\n"); fflush(stderr); */ if(JVMPTR->AttachCurrentThread(JVMPAR2 (void**)&cbenv, NULL) != 0) { diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index acf57c8..0d2999a 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -181,7 +181,6 @@ h5str_sprintf char *this_str; size_t this_strlen; int n; - int len; hvl_t *vlptr; char *cptr = (char*) ptr; unsigned char *ucptr = (unsigned char*) ptr; @@ -522,7 +521,6 @@ h5str_print_region_data_blocks hsize_t *count = NULL; hsize_t blkndx; hsize_t total_size[H5S_MAX_RANK]; - unsigned int region_flags; /* buffer extent flags */ hsize_t numelem; hsize_t numindex; size_t jndx; @@ -622,7 +620,6 @@ h5str_dump_region_blocks_data hsize_t *ptdata; hid_t dtype = -1; hid_t type_id = -1; - char tmp_str[256]; int ndims = H5Sget_simple_extent_ndims(region); /* @@ -634,8 +631,6 @@ h5str_dump_region_blocks_data /* Print block information */ if (nblocks > 0) { - int i; - alloc_size = (hsize_t)nblocks * (hsize_t)ndims * 2 * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); @@ -745,13 +740,10 @@ h5str_print_region_data_points hsize_t *dims1 = NULL; hsize_t total_size[H5S_MAX_RANK]; size_t jndx; - unsigned indx; size_t type_size; int ret_value = SUCCEED; - unsigned int region_flags; /* buffer extent flags */ hid_t mem_space = -1; void *region_buf = NULL; - char tmp_str[256]; /* Allocate space for the dimension array */ if((dims1 = (hsize_t *)HDmalloc(sizeof(hsize_t) * (size_t)ndims)) != NULL) { @@ -810,7 +802,6 @@ h5str_dump_region_points_data hssize_t npoints; hsize_t alloc_size; hsize_t *ptdata; - char tmp_str[256]; hid_t dtype = -1; hid_t type_id = -1; int ndims = H5Sget_simple_extent_ndims(region); @@ -824,8 +815,6 @@ h5str_dump_region_points_data /* Print point information */ if (npoints > 0) { - int i; - alloc_size = (hsize_t)npoints * (hsize_t)ndims * (hsize_t)sizeof(ptdata[0]); if (alloc_size == (hsize_t)((size_t) alloc_size)) { ptdata = (hsize_t *)HDmalloc((size_t) alloc_size); @@ -1297,7 +1286,7 @@ h5str_render_bin_output case H5T_ARRAY: { int k, ndims; - hsize_t i, dims[H5S_MAX_RANK], temp_nelmts, nelmts; + hsize_t dims[H5S_MAX_RANK], temp_nelmts, nelmts; hid_t memb; /* get the array's base datatype for each element */ @@ -1325,7 +1314,6 @@ h5str_render_bin_output break; case H5T_VLEN: { - unsigned int i; hsize_t nelmts; hid_t memb; @@ -1416,7 +1404,6 @@ render_bin_output_region_data_blocks hsize_t *start = NULL; hsize_t *count = NULL; hsize_t numelem; - hsize_t numindex; hsize_t total_size[H5S_MAX_RANK]; int jndx; size_t type_size; @@ -1587,7 +1574,6 @@ render_bin_output_region_data_points hid_t container, int ndims, hid_t type_id, hssize_t npoints, hsize_t *ptdata) { hsize_t *dims1 = NULL; - int jndx; size_t type_size; hid_t mem_space = -1; void *region_buf = NULL; @@ -1705,7 +1691,6 @@ h5str_dump_simple_dset int ndims; int carry; /* counter carry value */ hsize_t zero[8]; /* vector of zeros */ - unsigned int flags; /* buffer extent flags */ hsize_t total_size[H5S_MAX_RANK]; /* total size of dataset*/ /* Print info */ @@ -1862,7 +1847,6 @@ h5tools_dump_simple_data int line_count; unsigned char *mem = (unsigned char*)_mem; size_t size; /* datum size */ - H5T_class_t type_class; hsize_t i; /*element counter */ h5str_t buffer; /*string into which to render */ -- cgit v0.12 From e9d582a034b68a4b4485e2c71c089d9e52b63d52 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 20 Sep 2016 13:38:47 -0500 Subject: Chage command proces to generate file before use. --- fortran/src/CMakeLists.txt | 57 ++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 278f814..4a0928e 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -65,7 +65,6 @@ set_target_properties (H5_buildiface PROPERTIES ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - file (MAKE_DIRECTORY "${HDF5_F90_BINARY_DIR}/shared") if (WIN32) set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) @@ -154,6 +153,23 @@ endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- # Fortran Modules #----------------------------------------------------------------------------- +set (f90_F_GEN_SOURCES + ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff.F90 +) +set (CMD $) +add_custom_command ( + OUTPUT ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 + COMMAND ${CMD} + DEPENDS ${f90_F_GEN_SOURCES} +) +add_custom_target (H5gen ALL +#v3.2 BYPRODUCT ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 + #WORKING_DIRECTORY ${HDF5_F90_SRC_BINARY_DIR} + DEPENDS ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 +) + set (f90_F_BASE_SOURCES # generated files ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 @@ -176,50 +192,17 @@ set (f90_F_BASE_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.F90 ) - set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) + set (f90_F_SOURCES ${f90_F_BASE_SOURCES} # generated file - ${HDF5_F90_BINARY_DIR}/H5_gen.F90 + ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 ) -if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 PROPERTIES GENERATED TRUE) - set (f90_F_SOURCES_SHARED - ${f90_F_BASE_SOURCES} - - # generated file - ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 - - # normal distribution - ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 - ) -endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - - -set (CMD $) -add_custom_target (H5gen ALL - COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} - DEPENDS ${f90_F_BASE_SOURCES} -) -set_source_files_properties (${f90_F_SOURCES} PROPERTIES LANGUAGE Fortran) - -if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_custom_target (H5genSH ALL - COMMAND ${CMD} - #v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared - DEPENDS ${f90_F_BASE_SOURCES} - ) - set_source_files_properties (${f90_F_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) -endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - #----------------------------------------------------------------------------- # Add Main fortran library @@ -247,7 +230,7 @@ endif (WIN32) set (install_targets ${install_targets} ${HDF5_F90_LIB_TARGET}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) + add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") -- cgit v0.12 From 55fa38f3c9f63953caa25f769fda57dd1ee891b1 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 20 Sep 2016 15:27:26 -0500 Subject: Update generated files commands and properties --- fortran/src/CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 4a0928e..e346a54 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -92,6 +92,7 @@ add_custom_command ( WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types ) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 PROPERTIES GENERATED TRUE) #----------------------------------------------------------------------------- # f90CStub lib @@ -114,7 +115,6 @@ set (f90CStub_C_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/H5Tf.c ${HDF5_F90_SRC_SOURCE_DIR}/H5Zf.c ) - set_source_files_properties (${f90CStub_C_SOURCES} PROPERTIES LANGUAGE C) set (f90CStub_C_HDRS @@ -163,17 +163,14 @@ add_custom_command ( OUTPUT ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 COMMAND ${CMD} DEPENDS ${f90_F_GEN_SOURCES} + COMMENT "Generating H5_gen.F90" ) add_custom_target (H5gen ALL -#v3.2 BYPRODUCT ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 - #WORKING_DIRECTORY ${HDF5_F90_SRC_BINARY_DIR} DEPENDS ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 ) +set_source_files_properties (${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) set (f90_F_BASE_SOURCES - # generated files - ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 - # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5fortkit.F90 @@ -192,9 +189,11 @@ set (f90_F_BASE_SOURCES ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff.F90 ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.F90 ) -set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) set (f90_F_SOURCES + # generated file + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 + ${f90_F_BASE_SOURCES} # generated file -- cgit v0.12 From 347501aba2962691988e73ddb1b384397e507a80 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 20 Sep 2016 15:41:07 -0500 Subject: Add another source property --- fortran/src/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index e346a54..e237ec6 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -92,6 +92,7 @@ add_custom_command ( WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types ) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5f90i_gen.h PROPERTIES GENERATED TRUE) set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 PROPERTIES GENERATED TRUE) #----------------------------------------------------------------------------- -- cgit v0.12 From a3bd6e7aa4d9206004d16ea40aa95178392f2446 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 20 Sep 2016 16:57:42 -0500 Subject: Add target depends require separate folders --- fortran/src/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index e237ec6..527f71f 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -65,6 +65,7 @@ set_target_properties (H5_buildiface PROPERTIES ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + file (MAKE_DIRECTORY "${HDF5_F90_BINARY_DIR}/shared") if (WIN32) set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) @@ -161,15 +162,29 @@ set (f90_F_GEN_SOURCES ) set (CMD $) add_custom_command ( - OUTPUT ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 + OUTPUT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 COMMAND ${CMD} DEPENDS ${f90_F_GEN_SOURCES} - COMMENT "Generating H5_gen.F90" + COMMENT "Generating the H5_gen.F90 file" ) add_custom_target (H5gen ALL - DEPENDS ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 + DEPENDS ${HDF5_F90_BINARY_DIR}/H5_gen.F90 ) -set_source_files_properties (${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) + +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (CMDSH $) + add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 + COMMAND ${CMDSH} + DEPENDS ${f90_F_GEN_SOURCES} + COMMENT "Generating the H5_gen.F90 shared file" + ) + add_custom_target (H5genSH ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 + ) + set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 PROPERTIES GENERATED TRUE) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) set (f90_F_BASE_SOURCES # normal distribution @@ -198,11 +213,25 @@ set (f90_F_SOURCES ${f90_F_BASE_SOURCES} # generated file - ${HDF5_F90_SRC_BINARY_DIR}/H5_gen.F90 + ${HDF5_F90_BINARY_DIR}/H5_gen.F90 # normal distribution ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 ) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (f90_F_SOURCES_SHARED + # generated file + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 + + ${f90_F_BASE_SOURCES} + + # generated file + ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 + + # normal distribution + ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 + ) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- # Add Main fortran library @@ -228,9 +257,10 @@ if (WIN32) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_F90_LIB_TARGET}) +add_dependencies(${HDF5_F90_LIB_TARGET} H5gen) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES}) + add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") @@ -256,6 +286,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_F90_LIBSH_TARGET}) + add_dependencies(${HDF5_F90_LIBSH_TARGET} H5genSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- -- cgit v0.12 From 60adc706e6c8bdee4a2e9a7c211f2f2a12dfc355 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Tue, 20 Sep 2016 17:03:40 -0500 Subject: Add WORKING_DIR to command --- fortran/src/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index 527f71f..d4ca791 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -164,6 +164,7 @@ set (CMD $) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS ${f90_F_GEN_SOURCES} COMMENT "Generating the H5_gen.F90 file" ) @@ -177,6 +178,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/shared/H5_gen.F90 COMMAND ${CMDSH} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared DEPENDS ${f90_F_GEN_SOURCES} COMMENT "Generating the H5_gen.F90 shared file" ) -- cgit v0.12 From e219ee88e42c09ab75e97a04a1b42d0b1410e721 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 21 Sep 2016 10:46:03 -0500 Subject: Add gen file technique to HL and test fortran libraries --- fortran/test/CMakeLists.txt | 71 +++++++++++++++++++++++++++++++------------ hl/fortran/src/CMakeLists.txt | 64 ++++++++++++++++++++++++++++---------- 2 files changed, 100 insertions(+), 35 deletions(-) diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index d1ca6e8..fd6dd28 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -32,13 +32,19 @@ set_target_properties (H5_test_buildiface PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} ) -if (NOT SKIP_HDF5_FORTRAN_SHARED) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + file (MAKE_DIRECTORY "${HDF5_F90_BINARY_DIR}/shared") if (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) + set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) endif (WIN32) -endif (NOT SKIP_HDF5_FORTRAN_SHARED) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) +if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) +else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) +endif (WIN32) INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${MOD_BUILD_DIR}) @@ -75,29 +81,54 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) -set (HDF5_F90_TF_SOURCES - # generated files - ${HDF5_F90_BINARY_DIR}/tf_gen.F90 -) -set_source_files_properties ( - ${HDF5_F90_BINARY_DIR}/tf_gen.F90 - PROPERTIES GENERATED TRUE -) -set_source_files_properties (tf.F90 ${HDF5_F90_BINARY_DIR}/${HDF5_F90_TF_SOURCES} PROPERTIES LANGUAGE Fortran) - set (CMD $) -add_custom_target (H5testgen ALL +add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/tf_gen.F90 COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/tf_gen.F90 WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5_test_buildiface + COMMENT "Generating the tf_gen.F90 file" ) +add_custom_target (H5testgen ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/tf_gen.F90 +) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/tf_gen.F90 PROPERTIES GENERATED TRUE) -add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC tf.F90 ${HDF5_F90_TF_SOURCES}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED tf.F90 ${HDF5_F90_TF_SOURCES}) + set (CMDSH $) + add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + COMMAND ${CMDSH} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR}/shared + DEPENDS H5_test_buildiface + COMMENT "Generating the tf_gen.F90 shared file" + ) + add_custom_target (H5testgenSH ALL + DEPENDS ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + ) + set_source_files_properties (${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 PROPERTIES GENERATED TRUE) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + +set (HDF5_F90_TF_SOURCES + # generated files + ${HDF5_F90_BINARY_DIR}/tf_gen.F90 + + # normal distribution + tf.F90 +) +set_source_files_properties (${HDF5_F90_TF_SOURCES} PROPERTIES LANGUAGE Fortran) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (HDF5_F90_TF_SOURCES_SHARED + # generated file + ${HDF5_F90_BINARY_DIR}/shared/tf_gen.F90 + + # normal distribution + tf.F90 + ) + set_source_files_properties (${HDF5_F90_TF_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) +add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC ${HDF5_F90_TF_SOURCES}) TARGET_FORTRAN_PROPERTIES (${HDF5_F90_TEST_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_C_TEST_LIB_TARGET} @@ -118,6 +149,7 @@ if (WIN32) ) endif (WIN32) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED ${HDF5_F90_TF_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL") @@ -326,7 +358,8 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) if (WIN32 AND MSVC) target_link_libraries (fortranlib_test_F03-shared "ws2_32.lib") - endif (WIN32 AND MSVC) + endif (WIN32 AND MSVC)endif (NOT SKIP_HDF5_FORTRAN_SHARED) + target_include_directories (fortranlib_test_F03-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (fortranlib_test_F03-shared PROPERTIES LINKER_LANGUAGE Fortran diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6419ab8..82db6fe 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -37,6 +37,7 @@ set_target_properties (H5HL_buildiface PROPERTIES ) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + file (MAKE_DIRECTORY "${HDF5_HL_F90_SRC_BINARY_DIR}/shared") if (WIN32) set (MODSH_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) else (WIN32) @@ -111,30 +112,61 @@ set (HDF5_HL_F90_F_BASE_SOURCES ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.F90 ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.F90 ) -set (HDF5_HL_F90_F_SOURCES - ${HDF5_HL_F90_F_BASE_SOURCES} - # generated files - ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 - ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 +set (CMD $) +add_custom_command ( + OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR} + DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} + COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 files" +) +add_custom_target (H5HLgen ALL + DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 ) - -set_source_files_properties (${HDF5_HL_F90_F_SOURCES} PROPERTIES LANGUAGE Fortran) - set_source_files_properties ( ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 PROPERTIES GENERATED TRUE ) +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (CMDSH $) + add_custom_command ( + OUTPUT ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR}/shared + DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} + COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 shared files" + ) + add_custom_target (H5HLgen ALL + DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + ) + set_source_files_properties ( + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + PROPERTIES GENERATED TRUE + ) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) -set (CMD $) -add_custom_target (H5HLgen ALL - COMMAND ${CMD} -#v3.2 BYPRODUCT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 -#v3.2 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 - WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR} - DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} +set (HDF5_HL_F90_F_SOURCES + ${HDF5_HL_F90_F_BASE_SOURCES} + + # generated files + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 ) +set_source_files_properties (${HDF5_HL_F90_F_SOURCES} PROPERTIES LANGUAGE Fortran) + +if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) + set (HDF5_HL_F90_F_SOURCES_SHARED + ${HDF5_HL_F90_F_BASE_SOURCES} + + # generated files + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 + ) + set_source_files_properties (${HDF5_HL_F90_F_SOURCES_SHARED} PROPERTIES LANGUAGE Fortran) +endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SOURCES}) TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} STATIC " " " ") @@ -155,7 +187,7 @@ endif (WIN32) set (install_targets ${install_targets} ${HDF5_HL_F90_LIB_TARGET}) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) - add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES}) + add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") if (WIN32 AND MSVC) set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def") -- cgit v0.12 From 408aaba9022e427113db3fcca2c54e2fb6564d7f Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 21 Sep 2016 10:48:12 -0500 Subject: Add missing SH to target name --- hl/fortran/src/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 82db6fe..ead8aec 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -138,7 +138,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) DEPENDS ${HDF5_HL_F90_F_BASE_SOURCES} COMMENT "Generating the H5LTff_gen.F90, H5TBff_gen.F90 shared files" ) - add_custom_target (H5HLgen ALL + add_custom_target (H5HLgenSH ALL DEPENDS ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5LTff_gen.F90 ${HDF5_HL_F90_SRC_BINARY_DIR}/shared/H5TBff_gen.F90 ) set_source_files_properties ( -- cgit v0.12 From bc1d833a80190a83bb11151f2d60035acdae3d2c Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 21 Sep 2016 10:49:48 -0500 Subject: Fix typo --- fortran/test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index fd6dd28..baf7369 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -358,7 +358,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) if (WIN32 AND MSVC) target_link_libraries (fortranlib_test_F03-shared "ws2_32.lib") - endif (WIN32 AND MSVC)endif (NOT SKIP_HDF5_FORTRAN_SHARED) + endif (WIN32 AND MSVC) target_include_directories (fortranlib_test_F03-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) set_target_properties (fortranlib_test_F03-shared PROPERTIES -- cgit v0.12 From a25cf226632b039d8f97839bb160f229fd7d5286 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 21 Sep 2016 12:12:37 -0500 Subject: Correct clear objects working dir --- tools/h5ls/CMakeTests.cmake | 1 + tools/h5ls/CMakeTestsVDS.cmake | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/h5ls/CMakeTests.cmake b/tools/h5ls/CMakeTests.cmake index 009ea79..2367df8 100644 --- a/tools/h5ls/CMakeTests.cmake +++ b/tools/h5ls/CMakeTests.cmake @@ -258,6 +258,7 @@ tvldtypes2be.out tvldtypes2be.out.err ) + set_tests_properties (H5LS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5LS-clearall-objects PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") diff --git a/tools/h5ls/CMakeTestsVDS.cmake b/tools/h5ls/CMakeTestsVDS.cmake index 0d08774..e6c216d 100644 --- a/tools/h5ls/CMakeTestsVDS.cmake +++ b/tools/h5ls/CMakeTestsVDS.cmake @@ -73,7 +73,7 @@ add_test ( NAME H5LS-${resultfile}-clear-objects COMMAND ${CMAKE_COMMAND} - -E remove ./testfiles/${resultfile}.out ./testfiles/vds/${resultfile}.out.err + -E remove ./testfiles/vds/${resultfile}.out ./testfiles/vds/${resultfile}.out.err ) add_test ( NAME H5LS-${resultfile} @@ -127,6 +127,7 @@ tvds_layout-5.out tvds_layout-5.out.err ) + set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles/vds") if (NOT "${last_test}" STREQUAL "") set_tests_properties (H5LS_VDS-clearall-objects PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") -- cgit v0.12 From 583af563d9f7eb8cedba6a8bb12d3218f55addf6 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 21 Sep 2016 12:22:16 -0500 Subject: Add missing target depends command --- fortran/test/CMakeLists.txt | 3 +++ hl/fortran/src/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+) diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index baf7369..219f937 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -148,6 +148,8 @@ if (WIN32) COMPILE_DEFINITIONS "HDF5F90_WINDOWS" ) endif (WIN32) +add_dependencies(${HDF5_F90_TEST_LIB_TARGET} H5testgen) + if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED ${HDF5_F90_TF_SOURCES_SHARED}) set (SHARED_LINK_FLAGS " ") @@ -175,6 +177,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) COMPILE_DEFINITIONS "BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS" ) endif (WIN32) + add_dependencies(${HDF5_F90_TEST_LIBSH_TARGET} H5testgenSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index ead8aec..774aa7c 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -185,6 +185,7 @@ if (WIN32) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_HL_F90_LIB_TARGET}) +add_dependencies(${HDF5_HL_F90_LIB_TARGET} H5HLgen) if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SOURCES_SHARED}) @@ -209,6 +210,7 @@ if (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) ) endif (WIN32) set (install_targets ${install_targets} ${HDF5_HL_F90_LIBSH_TARGET}) + add_dependencies(${HDF5_HL_F90_LIBSH_TARGET} H5HLgenSH) endif (BUILD_SHARED_LIBS AND NOT SKIP_HDF5_FORTRAN_SHARED) #----------------------------------------------------------------------------- -- cgit v0.12 From fa66428a6dd3e9250497618afa6402008c7ed409 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 27 Sep 2016 10:29:16 -0700 Subject: Description: Further warning cleanups: from 667 warnings to 503. --- hl/test/test_ds.c | 9 ++++- hl/tools/gif2h5/h52gifgentst.c | 8 ++++- src/H5Aint.c | 5 ++- test/cmpd_dset.c | 53 ++++++++++++++++++++++----- test/dsets.c | 82 +++++++++++++++++++++++++++++++++++------- test/dt_arith.c | 7 ++-- test/gheap.c | 51 +++++++++++++++++++++++--- test/h5test.c | 29 +++++++++++---- test/tattr.c | 44 ++++++++++++++++------- test/tchecksum.c | 23 +++++++----- test/th5o.c | 32 ++++++++++------- test/theap.c | 44 ++++++++++++++++++----- test/titerate.c | 13 ++++--- test/tskiplist.c | 48 +++++++++++++++++++------ test/tvltypes.c | 12 +++++-- tools/h5dump/h5dumpgentest.c | 69 +++++++++++++++++++++++------------ 16 files changed, 409 insertions(+), 120 deletions(-) diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 47929e6..3ca1e4d 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -389,7 +389,7 @@ herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int int rank = 4; int rankds = 1; hsize_t dims[4] = {DIM1_SIZE,DIM2_SIZE,DIM3_SIZE,DIM4_SIZE}; - long buf[DIM1_SIZE*DIM2_SIZE*DIM3_SIZE*DIM4_SIZE]; + long *buf; hsize_t s1_dim[1] = {DIM1_SIZE}; hsize_t s2_dim[1] = {DIM2_SIZE}; hsize_t s3_dim[1] = {DIM3_SIZE}; @@ -409,6 +409,10 @@ herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int long s43_wbuf[DIM4_SIZE] = {180,180}; long s44_wbuf[DIM4_SIZE] = {280,280}; + /* Allocate buffer */ + buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE); + HDassert(buf); + /* make a dataset */ if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { if(fulldims==0) { @@ -444,6 +448,9 @@ herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int } else return FAIL; + + HDfree(buf); + return SUCCEED; } diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index 3433d0a..6a41028 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -13,6 +13,7 @@ * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +#include #include #include #include "hdf5.h" @@ -49,12 +50,15 @@ int main(void) { hid_t fid; int i, j, n, space; - unsigned char buf [ WIDTH*HEIGHT ]; + unsigned char *buf; unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */ hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */ hsize_t width = WIDTH; hsize_t height = HEIGHT; + /* Allocate buffer */ + buf = (unsigned char *)malloc(WIDTH * HEIGHT); + assert(buf); /* create a file */ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) @@ -99,6 +103,8 @@ int main(void) if(H5Fclose(fid)<0) return EXIT_FAILURE; + free(buf); + return EXIT_SUCCESS; } diff --git a/src/H5Aint.c b/src/H5Aint.c index ea90118..66af0ff 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -2106,10 +2106,9 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si HDmemcpy(buf, attr_src->shared->data, attr_src->shared->data_size); /* Allocate background memory */ - if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) { + if(H5T_path_bkg(tpath_src_mem) || H5T_path_bkg(tpath_mem_dst)) if(NULL == (bkg_buf = H5FL_BLK_CALLOC(attr_buf, buf_size))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed") - } + HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed") /* Convert from source file to memory */ if(H5T_convert(tpath_src_mem, tid_src, tid_mem, nelmts, (size_t)0, (size_t)0, buf, bkg_buf, dxpl_id) < 0) diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 311b9bb..a7f3902 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -154,30 +154,28 @@ static unsigned test_compound (char *filename, hid_t fapl) { /* First dataset */ - static s1_t s1[NX*NY]; + s1_t *s1 = NULL; hid_t s1_tid; /* Second dataset */ - static s2_t s2[NX*NY]; + s2_t *s2 = NULL; hid_t s2_tid; /* Third dataset */ - static s3_t s3[NX*NY]; + s3_t *s3 = NULL; hid_t s3_tid; /* Fourth dataset */ - static s4_t s4[NX*NY]; + s4_t *s4 = NULL; hid_t s4_tid; /* Fifth dataset */ - static s5_t s5[NX*NY]; + s5_t *s5 = NULL; hid_t s5_tid; - static s6_t s6[NX*NY]; - hid_t s6_tid; - - /* Sixth dataset */ + s6_t *s6 = NULL; + hid_t s6_tid; /* Seventh dataset */ hid_t s7_sid; @@ -204,6 +202,20 @@ test_compound (char *filename, hid_t fapl) hsize_t memb_size[1] = {4}; int ret_code; + /* Allocate buffers for datasets */ + if(NULL == (s1 = (s1_t *)HDmalloc(sizeof(s1_t) * NX * NY))) + goto error; + if(NULL == (s2 = (s2_t *)HDmalloc(sizeof(s2_t) * NX * NY))) + goto error; + if(NULL == (s3 = (s3_t *)HDmalloc(sizeof(s3_t) * NX * NY))) + goto error; + if(NULL == (s4 = (s4_t *)HDmalloc(sizeof(s4_t) * NX * NY))) + goto error; + if(NULL == (s5 = (s5_t *)HDmalloc(sizeof(s5_t) * NX * NY))) + goto error; + if(NULL == (s6 = (s6_t *)HDmalloc(sizeof(s6_t) * NX * NY))) + goto error; + /* Create the file */ if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) { goto error; @@ -848,11 +860,34 @@ test_compound (char *filename, hid_t fapl) H5Dclose (dataset); H5Fclose (file); + /* Release buffers */ + HDfree(s1); + HDfree(s2); + HDfree(s3); + HDfree(s4); + HDfree(s5); + HDfree(s6); + PASSED(); return 0; error: puts("*** DATASET TESTS FAILED ***"); + + /* Release resources */ + if(s1) + HDfree(s1); + if(s2) + HDfree(s2); + if(s3) + HDfree(s3); + if(s4) + HDfree(s4); + if(s5) + HDfree(s5); + if(s6) + HDfree(s6); + return 1; } diff --git a/test/dsets.c b/test/dsets.c index fe6a0c0..4a52539 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -7942,11 +7942,10 @@ test_big_chunks_bypass_cache(hid_t fapl) int fvalue = BYPASS_FILL_VALUE; /* Fill value */ hsize_t count, stride, offset, block; /* Setting for hyperslab (1-D) */ hsize_t t_count[2], t_stride[2], t_offset[2], t_block[2]; /* Setting for hyperslab (2-D) */ - /* Buffer for reading and writing data (1-D) */ - static int wdata[BYPASS_CHUNK_DIM/2], rdata1[BYPASS_DIM], - rdata2[BYPASS_CHUNK_DIM/2]; + /* Buffers for reading and writing data (1-D) */ + int *wdata = NULL, *rdata1 = NULL, *rdata2 = NULL; /* Buffer for reading and writing data (2-D) */ - static int t_wdata[BYPASS_CHUNK_DIM/2][BYPASS_CHUNK_DIM/2], t_rdata1[BYPASS_DIM][BYPASS_DIM], + int t_wdata[BYPASS_CHUNK_DIM/2][BYPASS_CHUNK_DIM/2], t_rdata1[BYPASS_DIM][BYPASS_DIM], t_rdata2[BYPASS_CHUNK_DIM/2][BYPASS_CHUNK_DIM/2]; int i, j; /* Local index variables */ H5F_libver_t low; /* File format low bound */ @@ -8031,6 +8030,14 @@ test_big_chunks_bypass_cache(hid_t fapl) if(H5Sselect_hyperslab(t_sid, H5S_SELECT_SET, t_offset, t_stride, t_count, t_block) < 0) FAIL_STACK_ERROR + /* Allocate buffers */ + if(NULL == (wdata = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) + TEST_ERROR + if(NULL == (rdata1 = (int *)HDmalloc(sizeof(int) * BYPASS_DIM))) + TEST_ERROR + if(NULL == (rdata2 = (int *)HDmalloc(sizeof(int) * (BYPASS_CHUNK_DIM / 2)))) + TEST_ERROR + /* Initialize data to write for 1-D dataset */ for(i = 0; i < BYPASS_CHUNK_DIM / 2; i++) wdata[i] = i; @@ -8165,6 +8172,11 @@ test_big_chunks_bypass_cache(hid_t fapl) if(H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR if(H5Fclose(fid) < 0) FAIL_STACK_ERROR + /* Release buffers */ + HDfree(wdata); + HDfree(rdata1); + HDfree(rdata2); + PASSED(); return 0; @@ -8179,6 +8191,12 @@ error: H5Sclose(t_sid); H5Fclose(fid); } H5E_END_TRY; + if(wdata) + HDfree(wdata); + if(rdata1) + HDfree(rdata1); + if(rdata2) + HDfree(rdata2); return -1; } /* end test_big_chunks_bypass_cache() */ @@ -9265,9 +9283,9 @@ test_fixed_array(hid_t fapl) hsize_t msize_big[1] = {POINTS_BIG}; /* Size of memory space for big dataset */ int wbuf[POINTS]; /* write buffer */ - int wbuf_big[POINTS_BIG]; /* write buffer for big dataset */ + int *wbuf_big = NULL; /* write buffer for big dataset */ int rbuf[POINTS]; /* read buffer */ - int rbuf_big[POINTS_BIG]; /* read buffer for big dataset */ + int *rbuf_big = NULL; /* read buffer for big dataset */ hsize_t chunk_dim2[2] = {4, 3}; /* Chunk dimensions */ int chunks[12][6]; /* # of chunks for dataset dimensions */ @@ -9309,6 +9327,12 @@ test_fixed_array(hid_t fapl) if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + /* Allocate the "big" buffers */ + if(NULL == (wbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) + TEST_ERROR + if(NULL == (rbuf_big = (int *)HDmalloc(sizeof(int) * POINTS_BIG))) + TEST_ERROR + #ifdef H5_HAVE_FILTER_DEFLATE /* Loop over compressing chunks */ for(compress = FALSE; compress <= TRUE; compress++) { @@ -9567,7 +9591,7 @@ test_fixed_array(hid_t fapl) /* Verify that written and read data are the same */ for(i = 0; i < POINTS_BIG; i++) - if(rbuf_big[i] != wbuf_big[i]){ + if(rbuf_big[i] != wbuf_big[i]) { printf(" Line %d: Incorrect value, wbuf_bif[%u]=%d, rbuf_big[%u]=%d\n", __LINE__,(unsigned)i,wbuf_big[i],(unsigned)i,rbuf_big[i]); TEST_ERROR; @@ -9599,6 +9623,10 @@ test_fixed_array(hid_t fapl) } /* end for */ #endif /* H5_HAVE_FILTER_DEFLATE */ + /* Release buffers */ + HDfree(wbuf_big); + HDfree(rbuf_big); + PASSED(); return 0; @@ -9610,6 +9638,10 @@ error: H5Sclose(mem_id); H5Fclose(fid); } H5E_END_TRY; + if(wbuf_big) + HDfree(wbuf_big); + if(rbuf_big) + HDfree(rbuf_big); return -1; } /* end test_fixed_array() */ @@ -9650,11 +9682,11 @@ test_single_chunk(hid_t fapl) hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */ hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */ hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ - hsize_t t_dim2[2] = {50, 100}; /* Dataset dimensions */ - int wbuf[DSET_DIM1*DSET_DIM2]; /* write buffer */ - int t_wbuf[50*100]; /* write buffer */ - int rbuf[DSET_DIM1*DSET_DIM2]; /* read buffer */ - int t_rbuf[50*100]; /* read buffer */ + hsize_t t_dim2[2] = {50, 100}; /* Dataset dimensions */ + int *wbuf = NULL; /* write buffer */ + int *t_wbuf = NULL; /* write buffer */ + int *rbuf = NULL; /* read buffer */ + int *t_rbuf = NULL; /* read buffer */ H5D_chunk_index_t idx_type; /* Dataset chunk index type */ H5F_libver_t low, high; /* File format bounds */ @@ -9686,6 +9718,16 @@ test_single_chunk(hid_t fapl) if((empty_size = h5_get_file_size(filename, fapl)) < 0) TEST_ERROR + /* Allocate the buffers */ + if(NULL == (wbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) + TEST_ERROR + if(NULL == (rbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) + TEST_ERROR + if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (50 * 100)))) + TEST_ERROR + if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (50 * 100)))) + TEST_ERROR + for(i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++) wbuf[i] = (int)n++; @@ -9800,7 +9842,7 @@ test_single_chunk(hid_t fapl) /* Open the second dataset */ if((did = H5Dopen2(fid, DSET_SINGLE_NOMAX, H5P_DEFAULT)) < 0) TEST_ERROR; - HDmemset(rbuf, 0, sizeof(rbuf)); + HDmemset(rbuf, 0, sizeof(int) * (DSET_DIM1 * DSET_DIM2)); /* Read from dataset */ if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) TEST_ERROR; @@ -9836,6 +9878,12 @@ test_single_chunk(hid_t fapl) } /* end for */ #endif /* H5_HAVE_FILTER_DEFLATE */ + /* Release buffers */ + HDfree(wbuf); + HDfree(rbuf); + HDfree(t_wbuf); + HDfree(t_rbuf); + PASSED(); return 0; @@ -9849,6 +9897,14 @@ error: H5Sclose(sid_max); H5Fclose(fid); } H5E_END_TRY; + if(wbuf) + HDfree(wbuf); + if(rbuf) + HDfree(rbuf); + if(t_wbuf) + HDfree(t_wbuf); + if(t_rbuf) + HDfree(t_rbuf); return -1; } /* end test_single_chunk() */ diff --git a/test/dt_arith.c b/test/dt_arith.c index 064ee69..cdfe182 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -2673,12 +2673,14 @@ test_conv_int_2(void) { int i, j; hid_t src_type, dst_type; - char buf[32*100]; + char *buf; printf("%-70s", "Testing overlap calculations"); HDfflush(stdout); - HDmemset(buf, 0, sizeof buf); + buf = (char *)HDcalloc(32, 100); + HDassert(buf); + for (i=1; i<=32; i++) { for (j=1; j<=32; j++) { @@ -2700,6 +2702,7 @@ test_conv_int_2(void) } } PASSED(); + HDfree(buf); return 0; } diff --git a/test/gheap.c b/test/gheap.c index 317e306..3e88ca6 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -78,7 +78,7 @@ test_1 (hid_t fapl) { hid_t file = -1; H5F_t *f = NULL; - H5HG_t obj[1024]; + H5HG_t *obj = NULL; uint8_t out[1024]; uint8_t in[1024]; size_t u; @@ -89,6 +89,10 @@ test_1 (hid_t fapl) TESTING("monotonically increasing lengths"); + /* Allocate buffer for H5HG_t */ + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -138,6 +142,10 @@ test_1 (hid_t fapl) } } + /* Release buffer */ + HDfree(obj); + obj = NULL; + if(H5Fclose(file) < 0) goto error; if(nerrors) goto error; @@ -148,6 +156,8 @@ error: H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; + if(obj) + HDfree(obj); return MAX(1, nerrors); } @@ -174,7 +184,7 @@ test_2 (hid_t fapl) { hid_t file = -1; H5F_t *f = NULL; - H5HG_t obj[1024]; + H5HG_t *obj = NULL; uint8_t out[1024]; uint8_t in[1024]; size_t u; @@ -184,6 +194,10 @@ test_2 (hid_t fapl) TESTING("monotonically decreasing lengths"); + /* Allocate buffer for H5HG_t */ + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -226,8 +240,13 @@ test_2 (hid_t fapl) } } + /* Release buffer */ + HDfree(obj); + obj = NULL; + if (H5Fclose(file)<0) goto error; if (nerrors) goto error; + PASSED(); return 0; @@ -235,6 +254,8 @@ test_2 (hid_t fapl) H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; + if(obj) + HDfree(obj); return MAX(1, nerrors); } @@ -261,7 +282,7 @@ test_3 (hid_t fapl) { hid_t file = -1; H5F_t *f = NULL; - H5HG_t obj[1024]; + H5HG_t *obj = NULL; uint8_t out[1024]; size_t u; size_t size; @@ -271,6 +292,10 @@ test_3 (hid_t fapl) TESTING("complete object removal"); + /* Allocate buffer for H5HG_t */ + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[2], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -304,8 +329,13 @@ test_3 (hid_t fapl) } } + /* Release buffer */ + HDfree(obj); + obj = NULL; + if (H5Fclose(file)<0) goto error; if (nerrors) goto error; + PASSED(); return 0; @@ -313,6 +343,8 @@ test_3 (hid_t fapl) H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; + if(obj) + HDfree(obj); return MAX(1, nerrors); } @@ -340,7 +372,7 @@ test_4 (hid_t fapl) { hid_t file = -1; H5F_t *f = NULL; - H5HG_t obj[1024]; + H5HG_t *obj = NULL; uint8_t out[1024]; size_t u; size_t size; @@ -350,6 +382,10 @@ test_4 (hid_t fapl) TESTING("partial object removal"); + /* Allocate buffer for H5HG_t */ + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + goto error; + /* Open a clean file */ h5_fixname(FILENAME[3], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) @@ -389,8 +425,13 @@ test_4 (hid_t fapl) } } + /* Release buffer */ + HDfree(obj); + obj = NULL; + if (H5Fclose(file)<0) goto error; if (nerrors) goto error; + PASSED(); return 0; @@ -398,6 +439,8 @@ test_4 (hid_t fapl) H5E_BEGIN_TRY { H5Fclose(file); } H5E_END_TRY; + if(obj) + HDfree(obj); return MAX(1, nerrors); } diff --git a/test/h5test.c b/test/h5test.c index aea5dc7..974f2e7 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -74,7 +74,7 @@ char *paraprefix = NULL; /* for command line option para-prefix */ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ #endif -#define READ_BUF_SIZE 4096 +#define READ_BUF_SIZE 65536 /* * These are the letters that are appended to the file name when generating @@ -855,7 +855,7 @@ h5_fileaccess(void) H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; + char *sv[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; @@ -867,6 +867,8 @@ h5_fileaccess(void) HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; + sv[mt] = (char *)HDmalloc(1024); + HDassert(sv[mt]); HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); @@ -874,6 +876,9 @@ h5_fileaccess(void) if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; + + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + HDfree(sv[mt]); } else if(!HDstrcmp(name, "family")) { hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -989,7 +994,7 @@ h5_get_vfd_fapl(void) H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; hid_t memb_fapl[H5FD_MEM_NTYPES]; const char *memb_name[H5FD_MEM_NTYPES]; - char sv[H5FD_MEM_NTYPES][1024]; + char *sv[H5FD_MEM_NTYPES]; haddr_t memb_addr[H5FD_MEM_NTYPES]; H5FD_mem_t mt; @@ -1001,15 +1006,18 @@ h5_get_vfd_fapl(void) HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; + sv[mt] = (char *)HDmalloc(1024); + HDassert(sv[mt]); HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); } /* end for */ - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, - memb_addr, FALSE) < 0) { + if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) return -1; - } /* end if */ + + for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) + HDfree(sv[mt]); } else if(!HDstrcmp(tok, "family")) { /* Family of files, each 1MB and using the default driver */ hsize_t fam_size = 100*1024*1024; /*100 MB*/ @@ -1573,9 +1581,13 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) { int fd_old = (-1), fd_new = (-1); /* File descriptors for copying data */ ssize_t nread; /* Number of bytes read in */ - char buf[READ_BUF_SIZE]; /* Buffer for copying data */ + void *buf; /* Buffer for copying data */ const char *filename = H5_get_srcdir_filename(origfilename);; /* Get the test file name to copy */ + /* Allocate copy buffer */ + if(NULL == (buf = HDmalloc(READ_BUF_SIZE))) + return -1; + /* Copy old file into temporary file */ if((fd_old = HDopen(filename, O_RDONLY, 0666)) < 0) return -1; @@ -1586,6 +1598,9 @@ h5_make_local_copy(const char *origfilename, const char *local_copy_name) while((nread = HDread(fd_old, buf, (size_t)READ_BUF_SIZE)) > 0) if(HDwrite(fd_new, buf, (size_t)nread) < 0) return -1; + + /* Release memory */ + HDfree(buf); /* Close files */ if(HDclose(fd_old) < 0) return -1; diff --git a/test/tattr.c b/test/tattr.c index e7b3ece..6f55081 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -8029,7 +8029,7 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -8040,8 +8040,10 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) /* Output message about test being performed */ MESSAGE(5, ("Testing Writing Shared & Unshared Attributes in Compact & Dense Storage\n")); - /* Initialize "big" attribute data */ - HDmemset(big_value, 1, sizeof(big_value)); + /* Allocate & initialize "big" attribute data */ + big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); + CHECK(big_value, NULL, "HDmalloc"); + HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); @@ -8328,6 +8330,9 @@ test_attr_shared_write(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(big_sid); CHECK(ret, FAIL, "H5Sclose"); + + /* Release memory */ + HDfree(big_value); } /* test_attr_shared_write() */ /**************************************************************** @@ -8355,7 +8360,7 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -8366,8 +8371,10 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) /* Output message about test being performed */ MESSAGE(5, ("Testing Renaming Shared & Unshared Attributes in Compact & Dense Storage\n")); - /* Initialize "big" attribute data */ - HDmemset(big_value, 1, sizeof(big_value)); + /* Allocate & initialize "big" attribute data */ + big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); + CHECK(big_value, NULL, "HDmalloc"); + HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); @@ -8770,6 +8777,9 @@ test_attr_shared_rename(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(big_sid); CHECK(ret, FAIL, "H5Sclose"); + + /* Release memory */ + HDfree(big_value); } /* test_attr_shared_rename() */ /**************************************************************** @@ -8796,7 +8806,7 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -8807,8 +8817,10 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) /* Output message about test being performed */ MESSAGE(5, ("Testing Deleting Shared & Unshared Attributes in Compact & Dense Storage\n")); - /* Initialize "big" attribute data */ - HDmemset(big_value, 1, sizeof(big_value)); + /* Allocate & initialize "big" attribute data */ + big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); + CHECK(big_value, NULL, "HDmalloc"); + HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); @@ -9134,6 +9146,9 @@ test_attr_shared_delete(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(big_sid); CHECK(ret, FAIL, "H5Sclose"); + + /* Release memory */ + HDfree(big_value); } /* test_attr_shared_delete() */ /**************************************************************** @@ -9160,7 +9175,7 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) htri_t is_shared; /* Is attributes shared? */ hsize_t shared_refcount; /* Reference count of shared attribute */ unsigned attr_value; /* Attribute value */ - unsigned big_value[SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3]; /* Data for "big" attribute */ + unsigned *big_value; /* Data for "big" attribute */ size_t mesg_count; /* # of shared messages */ unsigned test_shared; /* Index over shared component type */ unsigned u; /* Local index variable */ @@ -9171,8 +9186,10 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) /* Output message about test being performed */ MESSAGE(5, ("Testing Unlinking Object with Shared Attributes in Compact & Dense Storage\n")); - /* Initialize "big" attribute data */ - HDmemset(big_value, 1, sizeof(big_value)); + /* Allocate & initialize "big" attribute data */ + big_value = (unsigned *)HDmalloc((size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3) * sizeof(unsigned)); + CHECK(big_value, NULL, "HDmalloc"); + HDmemset(big_value, 1, sizeof(unsigned) * (size_t)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3)); /* Create dataspace for dataset */ sid = H5Screate(H5S_SCALAR); @@ -9484,6 +9501,9 @@ test_attr_shared_unlink(hid_t fcpl, hid_t fapl) CHECK(ret, FAIL, "H5Sclose"); ret = H5Sclose(big_sid); CHECK(ret, FAIL, "H5Sclose"); + + /* Release memory */ + HDfree(big_value); } /* test_attr_shared_unlink() */ /**************************************************************** diff --git a/test/tchecksum.c b/test/tchecksum.c index ca6c227..cf519c0 100644 --- a/test/tchecksum.c +++ b/test/tchecksum.c @@ -37,7 +37,6 @@ /*******************/ /* Local variables */ /*******************/ -uint8_t large_buf[BUF_LEN]; /**************************************************************** @@ -184,33 +183,41 @@ test_chksum_size_four(void) static void test_chksum_large(void) { + uint8_t *large_buf; /* Buffer for checksum calculations */ uint32_t chksum; /* Checksum value */ size_t u; /* Local index variable */ + /* Allocate the buffer */ + large_buf = (uint8_t *)HDmalloc((size_t)BUF_LEN); + CHECK(large_buf, NULL, "HDmalloc"); + /* Initialize buffer w/known data */ for(u = 0; u < BUF_LEN; u++) large_buf[u] = (uint8_t)(u * 3); /* Buffer w/real data */ - chksum = H5_checksum_fletcher32(large_buf, sizeof(large_buf)); + chksum = H5_checksum_fletcher32(large_buf, (size_t)BUF_LEN); VERIFY(chksum, 0x85b4e2a, "H5_checksum_fletcher32"); - chksum = H5_checksum_crc(large_buf, sizeof(large_buf)); + chksum = H5_checksum_crc(large_buf, (size_t)BUF_LEN); VERIFY(chksum, 0xfbd0f7c0, "H5_checksum_crc"); - chksum = H5_checksum_lookup3(large_buf, sizeof(large_buf), 0); + chksum = H5_checksum_lookup3(large_buf, (size_t)BUF_LEN, 0); VERIFY(chksum, 0x1bd2ee7b, "H5_checksum_lookup3"); /* Buffer w/zero(s) for data */ - HDmemset(large_buf, 0, sizeof(large_buf)); - chksum = H5_checksum_fletcher32(large_buf, sizeof(large_buf)); + HDmemset(large_buf, 0, (size_t)BUF_LEN); + chksum = H5_checksum_fletcher32(large_buf, (size_t)BUF_LEN); VERIFY(chksum, 0, "H5_checksum_fletcher32"); - chksum = H5_checksum_crc(large_buf, sizeof(large_buf)); + chksum = H5_checksum_crc(large_buf, (size_t)BUF_LEN); VERIFY(chksum, 0xfac8b4c4, "H5_checksum_crc"); - chksum = H5_checksum_lookup3(large_buf, sizeof(large_buf), 0); + chksum = H5_checksum_lookup3(large_buf, (size_t)BUF_LEN, 0); VERIFY(chksum, 0x930c7afc, "H5_checksum_lookup3"); + + /* Release memory for buffer */ + HDfree(large_buf); } /* test_chksum_large() */ diff --git a/test/th5o.c b/test/th5o.c index 125e11b..c2c4034 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -777,15 +777,21 @@ test_h5o_link(void) hsize_t dims[2] = {TEST6_DIM1, TEST6_DIM2}; htri_t committed; /* Whether the named datatype is committed */ unsigned new_format; /* Whether to use the new format or not */ - int wdata[TEST6_DIM1][TEST6_DIM2]; - int rdata[TEST6_DIM1][TEST6_DIM2]; - int i, n, j; + int *wdata; + int *rdata; + int i, n; herr_t ret; /* Value returned from API calls */ + /* Allocate memory buffers */ + /* (These are treated as 2-D buffers) */ + wdata = (int *)HDmalloc((size_t)(TEST6_DIM1 * TEST6_DIM2) * sizeof(int)); + CHECK(wdata, NULL, "HDmalloc"); + rdata = (int *)HDmalloc((size_t)(TEST6_DIM1 * TEST6_DIM2) * sizeof(int)); + CHECK(rdata, NULL, "HDmalloc"); + /* Initialize the raw data */ - for(i = n = 0; i < TEST6_DIM1; i++) - for(j = 0; j < TEST6_DIM2; j++) - wdata[i][j] = n++; + for(i = n = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + wdata[i] = n++; /* Create the dataspace */ space_id = H5Screate_simple(2 ,dims, NULL); @@ -840,9 +846,8 @@ test_h5o_link(void) CHECK(ret, FAIL, "H5Dread"); /* Verify the data */ - for(i = 0; i < TEST6_DIM1; i++) - for(j = 0; j < TEST6_DIM2; j++) - VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + VERIFY(wdata[i], rdata[i], "H5Dread"); /* Create a group with no name*/ group_id = H5Gcreate_anon(file_id, H5P_DEFAULT, H5P_DEFAULT); @@ -879,9 +884,8 @@ test_h5o_link(void) /* Read data from dataset */ ret = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata); CHECK(ret, FAIL, "H5Dread"); - for(i = 0; i < TEST6_DIM1; i++) - for(j = 0; j < TEST6_DIM2; j++) - VERIFY(wdata[i][j], rdata[i][j], "H5Dread"); + for(i = 0; i < (TEST6_DIM1 * TEST6_DIM2); i++) + VERIFY(wdata[i], rdata[i], "H5Dread"); /* Close open IDs */ ret = H5Dclose(dset_id); @@ -897,6 +901,10 @@ test_h5o_link(void) CHECK(ret, FAIL, "H5Sclose"); ret = H5Pclose(lcpl_id); CHECK(ret, FAIL, "H5Pclose"); + + /* Release buffers */ + HDfree(wdata); + HDfree(rdata); } /* end test_h5o_link() */ diff --git a/test/theap.c b/test/theap.c index 2d509bf..b19e08f 100644 --- a/test/theap.c +++ b/test/theap.c @@ -44,13 +44,13 @@ typedef struct test_obj { } test_obj; /* Array of random element values */ -static test_obj rand_num[NUM_ELEMS]; +static test_obj *rand_num; /* Array of random elements values, sorted in increasing order */ -static test_obj inc_sort_num[NUM_ELEMS]; +static test_obj *inc_sort_num; /* Array of random elements values, sorted in decreasing order */ -static test_obj dec_sort_num[NUM_ELEMS]; +static test_obj *dec_sort_num; static int tst_dec_sort(const void *_i1, const void *_i2) { @@ -88,21 +88,29 @@ test_heap_init(void) time_t curr_time; /* Current time, for seeding random number generator */ size_t u; /* Local index variables */ + /* Allocate arrays */ + rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + HDassert(rand_num); + inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + HDassert(inc_sort_num); + dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + HDassert(dec_sort_num); + /* Create randomized set of numbers */ - curr_time=time(NULL); + curr_time = HDtime(NULL); HDsrandom((unsigned)curr_time); - for(u=0; u= 0); } + /* * Close and release resources. */ @@ -3505,6 +3510,7 @@ static void gent_array8(void) HDassert(status >= 0); status = H5Fclose (file); HDassert(status >= 0); + HDfree(wdata); } static void gent_empty(void) @@ -7585,7 +7591,7 @@ static void gent_compound_intsizes(void) { int64_t dset64[F70_XDIM][F70_YDIM64]; double dsetdbl[F70_XDIM][F70_YDIM8]; } Array1Struct; - Array1Struct Array1[F70_LENGTH]; + Array1Struct *Array1; hid_t Array1Structid; /* File datatype identifier */ herr_t status; /* Error checking variable */ @@ -7593,6 +7599,10 @@ static void gent_compound_intsizes(void) { int m, n, o; /* Array init loop vars */ + /* Allocate buffer */ + Array1 = (Array1Struct *)HDmalloc(sizeof(Array1Struct) * F70_LENGTH); + HDassert(Array1); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F70_LENGTH; m++) { @@ -7602,9 +7612,8 @@ static void gent_compound_intsizes(void) { valu8bits = (uint8_t) ~0u; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dsetu8[n][0] = valu8bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dsetu8[n][o] = (uint8_t)(Array1[m].dsetu8[n][o-1] << 1); - } valu8bits = (uint8_t)(valu8bits << 1); } @@ -7614,9 +7623,8 @@ static void gent_compound_intsizes(void) { valu16bits = (uint16_t) ~0u; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dsetu16[n][0] = valu16bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dsetu16[n][o] = (uint16_t)(Array1[m].dsetu16[n][o-1] << 1); - } valu16bits = (uint16_t)(valu16bits << 1); } @@ -7626,9 +7634,8 @@ static void gent_compound_intsizes(void) { valu32bits = (uint32_t) ~0u; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dsetu32[n][0] = valu32bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dsetu32[n][o] = Array1[m].dsetu32[n][o-1] << 1; - } valu32bits <<= 1; } @@ -7638,9 +7645,8 @@ static void gent_compound_intsizes(void) { valu64bits = (uint64_t) ~0Lu; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dsetu64[n][0] = valu64bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dsetu64[n][o] = Array1[m].dsetu64[n][o-1] << 1; - } valu64bits <<= 1; } @@ -7650,9 +7656,8 @@ static void gent_compound_intsizes(void) { val8bits = (int8_t) ~0; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dset8[n][0] = val8bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dset8[n][o] = (int8_t)(Array1[m].dset8[n][o-1] << 1); - } val8bits = (int8_t)(val8bits << 1); } @@ -7662,9 +7667,8 @@ static void gent_compound_intsizes(void) { val16bits = (int16_t) ~0; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dset16[n][0] = val16bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dset16[n][o] = (int16_t)(Array1[m].dset16[n][o-1] << 1); - } val16bits = (int16_t)(val16bits << 1); } @@ -7674,9 +7678,8 @@ static void gent_compound_intsizes(void) { val32bits = (int32_t) ~0; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dset32[n][0] = val32bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dset32[n][o] = Array1[m].dset32[n][o-1] << 1; - } val32bits <<= 1; } @@ -7686,9 +7689,8 @@ static void gent_compound_intsizes(void) { val64bits = (int64_t) ~0L; /* all 1s */ for(n = 0; n < (int)dims[0]; n++){ Array1[m].dset64[n][0] = val64bits; - for(o = 1; o < (int)dims[1]; o++) { + for(o = 1; o < (int)dims[1]; o++) Array1[m].dset64[n][o] = Array1[m].dset64[n][o-1] << 1; - } val64bits <<= 1; } @@ -7822,6 +7824,8 @@ static void gent_compound_intsizes(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Array1); } static void gent_compound_attr_intsizes(void) { @@ -8736,7 +8740,7 @@ static void gent_compound_int_array(void) { int64_t dset64[F76_DIM64]; double dsetdbl[F76_DIM8]; } Cmpd1Struct; - Cmpd1Struct Cmpd1[F76_LENGTH]; + Cmpd1Struct *Cmpd1; hid_t Cmpd1Structid; /* File datatype identifier */ herr_t status; /* Error checking variable */ @@ -8744,6 +8748,10 @@ static void gent_compound_int_array(void) { int m, n; /* Array init loop vars */ + /* Allocate buffer */ + Cmpd1 = (Cmpd1Struct *)HDmalloc(sizeof(Cmpd1Struct) * F76_LENGTH); + HDassert(Cmpd1); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F76_LENGTH; m++) { @@ -8948,6 +8956,8 @@ static void gent_compound_int_array(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Cmpd1); } static void gent_compound_ints(void) { @@ -8972,7 +8982,7 @@ static void gent_compound_ints(void) { int64_t dset64; double dsetdbl; } Cmpd1Struct; - Cmpd1Struct Cmpd1[F77_LENGTH]; + Cmpd1Struct *Cmpd1; typedef struct Cmpd2Struct { uint64_t dsetu64; @@ -8985,7 +8995,7 @@ static void gent_compound_ints(void) { int8_t dset8; double dsetdbl; } Cmpd2Struct; - Cmpd2Struct Cmpd2[F77_LENGTH]; + Cmpd2Struct *Cmpd2; hid_t Cmpd1Structid; /* File datatype identifier */ hid_t Cmpd2Structid; /* File datatype identifier */ @@ -8994,6 +9004,12 @@ static void gent_compound_ints(void) { int m; /* Array init loop vars */ + /* Allocate buffers */ + Cmpd1 = (Cmpd1Struct *)HDmalloc(sizeof(Cmpd1Struct) * F77_LENGTH); + HDassert(Cmpd1); + Cmpd2 = (Cmpd2Struct *)HDmalloc(sizeof(Cmpd2Struct) * F77_LENGTH); + HDassert(Cmpd2); + /* Initialize the data in the arrays/datastructure */ for (m = 0; m < F77_LENGTH; m++) { @@ -9170,6 +9186,9 @@ static void gent_compound_ints(void) { status = H5Fclose(fid); HDassert(status >= 0); + + HDfree(Cmpd1); + HDfree(Cmpd2); } /*------------------------------------------------------------------------- @@ -9918,7 +9937,7 @@ static void gent_compound_complex2(void) multiple_nested_compound e; /* Compound inside compound with further nested compound */ } compound; - compound buf[F82_DIM32]; /* compound */ + compound *buf; /* compound */ hid_t file, type=-1, space=-1, dset=-1; hid_t dset_array_a, dset_array_b, dset_array_c; @@ -9929,6 +9948,10 @@ static void gent_compound_complex2(void) hsize_t dset_array_a_dims[1], dset_array_b_dims[1], dset_array_c_dims[2]; hsize_t nelmts = F82_DIM32; + /* Allocate buffer */ + buf = (compound *)HDmalloc(sizeof(compound) * F82_DIM32); + HDassert(buf); + file = H5Fcreate(FILE82, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); if ((space = H5Screate_simple(F82_RANK, &nelmts, NULL)) >= 0) { @@ -10176,6 +10199,8 @@ static void gent_compound_complex2(void) // } H5Fclose(file); + + HDfree(buf); } /*------------------------------------------------------------------------- -- cgit v0.12 From 1853868fdc9433f29adae5418d1fd0d65a45fabe Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 29 Sep 2016 11:01:23 -0700 Subject: Description: Cleanups from Dana's review. Tested on: MacOSX/64 10.11.5 (amazon) w/C++ & FORTRAN (h5committest forthcoming) --- hl/test/test_ds.c | 4 ++-- hl/tools/gif2h5/h52gifgentst.c | 4 ++-- test/h5test.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c index 3ca1e4d..091a98b 100644 --- a/hl/test/test_ds.c +++ b/hl/test/test_ds.c @@ -410,8 +410,8 @@ herr_t create_long_dataset(hid_t fid, const char *dsname, const char *dsidx, int long s44_wbuf[DIM4_SIZE] = {280,280}; /* Allocate buffer */ - buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE); - HDassert(buf); + if(NULL == (buf = (long *)HDmalloc(sizeof(long) * DIM1_SIZE * DIM2_SIZE * DIM3_SIZE * DIM4_SIZE))) + return FAIL; /* make a dataset */ if(H5LTmake_dataset_long(fid, dsname, rank, dims, buf) >= 0) { diff --git a/hl/tools/gif2h5/h52gifgentst.c b/hl/tools/gif2h5/h52gifgentst.c index 6a41028..39e950b 100644 --- a/hl/tools/gif2h5/h52gifgentst.c +++ b/hl/tools/gif2h5/h52gifgentst.c @@ -57,8 +57,8 @@ int main(void) hsize_t height = HEIGHT; /* Allocate buffer */ - buf = (unsigned char *)malloc(WIDTH * HEIGHT); - assert(buf); + if(NULL == (buf = (unsigned char *)malloc(WIDTH * HEIGHT))) + return EXIT_FAILURE; /* create a file */ if ((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT))<0) diff --git a/test/h5test.c b/test/h5test.c index 974f2e7..92b90c5 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -867,8 +867,8 @@ h5_fileaccess(void) HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; - sv[mt] = (char *)HDmalloc(1024); - HDassert(sv[mt]); + if(NULL == (sv[mt] = (char *)HDmalloc(1024))) + return -1; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); -- cgit v0.12 From 5a7880183025f56421cf6f2274d9f1ac36f59641 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 29 Sep 2016 13:17:55 -0700 Subject: Clean up hardcoded constants and check return values better. (Comments from group code review) --- test/dsets.c | 16 ++++++++++------ test/dt_arith.c | 11 +++++++---- test/gheap.c | 41 ++++++++++++++++++++++------------------- test/h5test.c | 7 +++++-- test/theap.c | 15 +++++++++------ test/tskiplist.c | 15 +++++++++------ 6 files changed, 62 insertions(+), 43 deletions(-) diff --git a/test/dsets.c b/test/dsets.c index 4a52539..8aa073f 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -240,6 +240,10 @@ double points_dbl[DSET_DIM1][DSET_DIM2], check_dbl[DSET_DIM1][DSET_DIM2]; size_t count_nbytes_read = 0; size_t count_nbytes_written = 0; +/* Temporary buffer dimensions */ +#define DSET_TMP_DIM1 50 +#define DSET_TMP_DIM2 100 + /* Declarations for test_idx_compatible() */ #define DSET "dset" #define DSET_FILTER "dset_filter" @@ -9682,7 +9686,7 @@ test_single_chunk(hid_t fapl) hid_t sid = -1, sid_max = -1; /* Dataspace ID for dataset with fixed dimensions */ hid_t did = -1, did_max = -1; /* Dataset ID for dataset with fixed dimensions */ hsize_t dim2[2] = {DSET_DIM1, DSET_DIM2}; /* Dataset dimensions */ - hsize_t t_dim2[2] = {50, 100}; /* Dataset dimensions */ + hsize_t t_dim2[2] = {DSET_TMP_DIM1, DSET_TMP_DIM2}; /* Dataset dimensions */ int *wbuf = NULL; /* write buffer */ int *t_wbuf = NULL; /* write buffer */ int *rbuf = NULL; /* read buffer */ @@ -9723,15 +9727,15 @@ test_single_chunk(hid_t fapl) TEST_ERROR if(NULL == (rbuf = (int *)HDmalloc(sizeof(int) * (DSET_DIM1 * DSET_DIM2)))) TEST_ERROR - if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (50 * 100)))) + if(NULL == (t_wbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) TEST_ERROR - if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (50 * 100)))) + if(NULL == (t_rbuf = (int *)HDmalloc(sizeof(int) * (DSET_TMP_DIM1 * DSET_TMP_DIM2)))) TEST_ERROR for(i = n = 0; i < (DSET_DIM1 * DSET_DIM2); i++) wbuf[i] = (int)n++; - for(i = n = 0; i < (50* 100); i++) + for(i = n = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++) t_wbuf[i] = (int)n++; #ifdef H5_HAVE_FILTER_DEFLATE @@ -9848,8 +9852,8 @@ test_single_chunk(hid_t fapl) if(H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, t_rbuf) < 0) TEST_ERROR; /* Verify that written and read data are the same */ - for(i = 0; i < (50* 100); i++) - if(t_rbuf[i] != t_wbuf[i]){ + for(i = 0; i < (DSET_TMP_DIM1* DSET_TMP_DIM2); i++) + if(t_rbuf[i] != t_wbuf[i]) { printf(" Line %d: Incorrect value, t_wbuf[%u]=%d, t_rbuf[%u]=%d\n", __LINE__,(unsigned)i,t_wbuf[i],(unsigned)i,t_rbuf[i]); TEST_ERROR; diff --git a/test/dt_arith.c b/test/dt_arith.c index cdfe182..1ebcf74 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -94,6 +94,9 @@ static int skip_overflow_tests_g = 0; #define TEST_DENORM 2 #define TEST_SPECIAL 3 +/* Temporary buffer sizes */ +#define TMP_BUF_DIM1 32 +#define TMP_BUF_DIM2 100 /* Don't use hardware conversions if set */ static int without_hardware_g = 0; @@ -2678,11 +2681,11 @@ test_conv_int_2(void) printf("%-70s", "Testing overlap calculations"); HDfflush(stdout); - buf = (char *)HDcalloc(32, 100); + buf = (char *)HDcalloc(TMP_BUF_DIM1, TMP_BUF_DIM2); HDassert(buf); - for (i=1; i<=32; i++) { - for (j=1; j<=32; j++) { + for(i = 1; i <= TMP_BUF_DIM1; i++) { + for(j = 1; j <= TMP_BUF_DIM1; j++) { /* Source type */ src_type = H5Tcopy(H5T_NATIVE_CHAR); @@ -2696,7 +2699,7 @@ test_conv_int_2(void) * Conversion. If overlap calculations aren't right then an * assertion will fail in H5T__conv_i_i() */ - H5Tconvert(src_type, dst_type, (size_t)100, buf, NULL, H5P_DEFAULT); + H5Tconvert(src_type, dst_type, (size_t)TMP_BUF_DIM2, buf, NULL, H5P_DEFAULT); H5Tclose(src_type); H5Tclose(dst_type); } diff --git a/test/gheap.c b/test/gheap.c index 3e88ca6..eafc49d 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -35,6 +35,9 @@ * GHEAP_REPEATED_ERR_LIM errors, and suppress the rest */ #define GHEAP_REPEATED_ERR_LIM 20 +/* Number of heap objects to test */ +#define GHEAP_TEST_NOBJS 1024 + #define GHEAP_REPEATED_ERR(MSG) \ { \ nerrors++; \ @@ -79,8 +82,8 @@ test_1 (hid_t fapl) hid_t file = -1; H5F_t *f = NULL; H5HG_t *obj = NULL; - uint8_t out[1024]; - uint8_t in[1024]; + uint8_t out[GHEAP_TEST_NOBJS]; + uint8_t in[GHEAP_TEST_NOBJS]; size_t u; size_t size; herr_t status; @@ -90,7 +93,7 @@ test_1 (hid_t fapl) TESTING("monotonically increasing lengths"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ @@ -108,7 +111,7 @@ test_1 (hid_t fapl) * a clean file, the addresses allocated for the collections should also * be monotonically increasing. */ - for(u = 0; u < 1024; u++) { + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u + 1; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); @@ -127,7 +130,7 @@ test_1 (hid_t fapl) /* * Now try to read each object back. */ - for(u = 0; u < 1024; u++) { + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u + 1; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); @@ -185,8 +188,8 @@ test_2 (hid_t fapl) hid_t file = -1; H5F_t *f = NULL; H5HG_t *obj = NULL; - uint8_t out[1024]; - uint8_t in[1024]; + uint8_t out[GHEAP_TEST_NOBJS]; + uint8_t in[GHEAP_TEST_NOBJS]; size_t u; size_t size; int nerrors = 0; @@ -195,7 +198,7 @@ test_2 (hid_t fapl) TESTING("monotonically decreasing lengths"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ @@ -211,8 +214,8 @@ test_2 (hid_t fapl) /* * Write the objects, monotonically decreasing in length. */ - for(u = 0; u < 1024; u++) { - size = 1024 - u; + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + size = GHEAP_TEST_NOBJS - u; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); if (H5HG_insert (f, H5AC_ind_read_dxpl_id, size, out, obj + u) < 0) { @@ -225,8 +228,8 @@ test_2 (hid_t fapl) /* * Now try to read each object back. */ - for(u = 0; u < 1024; u++) { - size = 1024 - u; + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { + size = GHEAP_TEST_NOBJS - u; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); if (NULL==H5HG_read (f, H5AC_ind_read_dxpl_id, obj + u, in, NULL)) { @@ -283,7 +286,7 @@ test_3 (hid_t fapl) hid_t file = -1; H5F_t *f = NULL; H5HG_t *obj = NULL; - uint8_t out[1024]; + uint8_t out[GHEAP_TEST_NOBJS]; size_t u; size_t size; herr_t status; @@ -293,7 +296,7 @@ test_3 (hid_t fapl) TESTING("complete object removal"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ @@ -307,7 +310,7 @@ test_3 (hid_t fapl) } /* Create some stuff */ - for(u = 0; u < 1024; u++) { + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { size = u % 30 + 100; HDmemset(out, (int)('A' + u % 26), size); H5Eclear2(H5E_DEFAULT); @@ -320,7 +323,7 @@ test_3 (hid_t fapl) } /* Remove everything */ - for(u = 0; u < 1024; u++) { + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { status = H5HG_remove (f, H5AC_ind_read_dxpl_id, obj + u); if (status<0) { H5_FAILED(); @@ -373,7 +376,7 @@ test_4 (hid_t fapl) hid_t file = -1; H5F_t *f = NULL; H5HG_t *obj = NULL; - uint8_t out[1024]; + uint8_t out[GHEAP_TEST_NOBJS]; size_t u; size_t size; herr_t status; @@ -383,7 +386,7 @@ test_4 (hid_t fapl) TESTING("partial object removal"); /* Allocate buffer for H5HG_t */ - if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * 1024))) + if(NULL == (obj = (H5HG_t *)HDmalloc(sizeof(H5HG_t) * GHEAP_TEST_NOBJS))) goto error; /* Open a clean file */ @@ -396,7 +399,7 @@ test_4 (hid_t fapl) goto error; } - for(u = 0; u < 1024; u++) { + for(u = 0; u < GHEAP_TEST_NOBJS; u++) { /* Insert */ size = u % 30 + 100; HDmemset(out, (int)('A' + u % 26), size); diff --git a/test/h5test.c b/test/h5test.c index 92b90c5..2ab8855 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -90,6 +90,9 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ */ static const char *multi_letters = "msbrglo"; +/* Length of multi-file VFD filename buffers */ +#define H5TEST_MULTI_FILENAME_LEN 1024 + /* Previous error reporting function */ static H5E_auto2_t err_func = NULL; @@ -867,7 +870,7 @@ h5_fileaccess(void) HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; - if(NULL == (sv[mt] = (char *)HDmalloc(1024))) + if(NULL == (sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN))) return -1; HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; @@ -1006,7 +1009,7 @@ h5_get_vfd_fapl(void) HDassert(HDstrlen(multi_letters) == H5FD_MEM_NTYPES); for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { memb_fapl[mt] = H5P_DEFAULT; - sv[mt] = (char *)HDmalloc(1024); + sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN); HDassert(sv[mt]); HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); memb_name[mt] = sv[mt]; diff --git a/test/theap.c b/test/theap.c index b19e08f..9c509a1 100644 --- a/test/theap.c +++ b/test/theap.c @@ -90,11 +90,11 @@ test_heap_init(void) /* Allocate arrays */ rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - HDassert(rand_num); + CHECK(rand_num, NULL, "HDmalloc"); inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - HDassert(inc_sort_num); + CHECK(inc_sort_num, NULL, "HDmalloc"); dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); - HDassert(dec_sort_num); + CHECK(dec_sort_num, NULL, "HDmalloc"); /* Create randomized set of numbers */ curr_time = HDtime(NULL); @@ -1039,9 +1039,12 @@ static void test_heap_term(void) { /* Release arrays */ - HDfree(rand_num); - HDfree(inc_sort_num); - HDfree(dec_sort_num); + if(rand_num) + HDfree(rand_num); + if(inc_sort_num) + HDfree(inc_sort_num); + if(dec_sort_num) + HDfree(dec_sort_num); } /* end test_tst_term() */ /**************************************************************** diff --git a/test/tskiplist.c b/test/tskiplist.c index 5738aad..f30948e 100644 --- a/test/tskiplist.c +++ b/test/tskiplist.c @@ -68,11 +68,11 @@ test_skiplist_init(void) /* Allocate arrays */ rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - HDassert(rand_num); + CHECK(rand_num, NULL, "HDmalloc"); sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - HDassert(sort_rand_num); + CHECK(sort_rand_num, NULL, "HDmalloc"); rev_sort_rand_num = (int *)HDmalloc(sizeof(int) * NUM_ELEMS); - HDassert(rev_sort_rand_num); + CHECK(rev_sort_rand_num, NULL, "HDmalloc"); /* Initialize random number seed */ curr_time = HDtime(NULL); @@ -1762,9 +1762,12 @@ static void test_skiplist_term(void) { /* Release arrays */ - HDfree(rand_num); - HDfree(sort_rand_num); - HDfree(rev_sort_rand_num); + if(rand_num) + HDfree(rand_num); + if(sort_rand_num) + HDfree(sort_rand_num); + if(rev_sort_rand_num) + HDfree(rev_sort_rand_num); } /* end test_skiplist_term() */ /**************************************************************** -- cgit v0.12