From 3efed9c1110521a8361603436984a677f2bbea29 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Sat, 25 Apr 2020 16:49:04 -0700 Subject: Fixes for warnings in the tools code. --- test/h5test.h | 59 ++++ tools/lib/h5diff.h | 6 +- tools/src/h5diff/h5diff_common.c | 18 +- tools/src/h5dump/h5dump_xml.c | 6 +- tools/src/h5jam/h5jam.c | 2 +- tools/test/h5dump/CMakeLists.txt | 2 +- tools/test/h5dump/Makefile.am | 2 +- tools/test/h5dump/h5dumpgentest.c | 475 ++++++++++++++++++++++++-------- tools/test/h5import/h5importtest.c | 9 +- tools/test/h5repack/CMakeLists.txt | 2 +- tools/test/h5repack/h5repacktst.c | 543 +++++++++++++++++++------------------ tools/test/misc/CMakeLists.txt | 2 +- tools/test/misc/Makefile.am | 2 +- tools/test/misc/h5clear_gentest.c | 24 +- tools/test/perform/pio_perf.c | 8 +- tools/test/perform/sio_perf.c | 8 +- tools/test/perform/zip_perf.c | 4 +- 17 files changed, 754 insertions(+), 418 deletions(-) diff --git a/test/h5test.h b/test/h5test.h index 398010b..2216069 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -126,6 +126,65 @@ H5TEST_DLLVAR MPI_Info h5_io_info_g; /* MPI INFO object for IO */ #define H5_FILEACCESS_VFD 0x01 #define H5_FILEACCESS_LIBVER 0x02 +/* Macros to create and fill 2D arrays with a single heap allocation. + * These can be used to replace large stack and global arrays which raise + * warnings. + * + * The macros make a single heap allocation large enough to hold all the + * pointers and the data elements. The first part of the allocation holds + * the pointers, and the second part holds the data as a contiguous block + * in row-major order. + * + * To pass the data block to calls like H5Dread(), pass a pointer to the + * first array element as the data pointer (e.g., array[0] in a 2D array). + * + * The fill macro just fills the array with an increasing count value. + * + * Usage: + * + * int **array; + * + * H5TEST_ALLOCATE_2D_ARRAY(array, int, 5, 10); + * + * H5TEST_FILL_2D_ARRAY(array, int, 5, 10); + * + * (do stuff) + * + * HDfree(array); + */ +#define H5TEST_ALLOCATE_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ +{ \ + /* Prefix with h5taa to avoid shadow warnings */ \ + size_t h5taa_pointers_size = 0; \ + size_t h5taa_data_size = 0; \ + int h5taa_i; \ + \ + h5taa_pointers_size = (DIMS_I) * sizeof(TYPE *); \ + h5taa_data_size = (DIMS_I) * (DIMS_J) * sizeof(TYPE); \ + \ + ARR = (TYPE **)HDmalloc(h5taa_pointers_size + h5taa_data_size); \ + \ + ARR[0] = (TYPE *)(ARR + (DIMS_I)); \ + \ + for (h5taa_i = 1; h5taa_i < (DIMS_I); h5taa_i++) \ + ARR[h5taa_i] = ARR[h5taa_i-1] + (DIMS_J); \ +} + +#define H5TEST_FILL_2D_ARRAY(ARR, TYPE, DIMS_I, DIMS_J) \ +{ \ + /* Prefix with h5tfa to avoid shadow warnings */ \ + int h5tfa_i = 0; \ + int h5tfa_j = 0; \ + TYPE h5tfa_count = 0; \ + \ + for (h5tfa_i = 0; h5tfa_i < (DIMS_I); h5tfa_i++) \ + for (h5tfa_j = 0; h5tfa_j < (DIMS_J); h5tfa_j++) { \ + ARR[h5tfa_i][h5tfa_j] = h5tfa_count; \ + h5tfa_count++; \ + } \ +} + + #ifdef __cplusplus extern "C" { #endif diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 8fe9d86..37eb775 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -53,9 +53,9 @@ typedef struct { */ /* linked list to keep exclude path list */ struct exclude_path_list { - char *obj_path; - h5trav_type_t obj_type; - struct exclude_path_list * next; + const char *obj_path; + h5trav_type_t obj_type; + struct exclude_path_list *next; }; /* Enumeration value for keeping track of whether an error occurred or differences were found */ diff --git a/tools/src/h5diff/h5diff_common.c b/tools/src/h5diff/h5diff_common.c index 771b20f..e0e6f8c 100644 --- a/tools/src/h5diff/h5diff_common.c +++ b/tools/src/h5diff/h5diff_common.c @@ -197,7 +197,7 @@ void parse_command_line(int argc, } /* init */ - exclude_node->obj_path = (char*)opt_arg; + exclude_node->obj_path = opt_arg; exclude_node->obj_type = H5TRAV_TYPE_UNKNOWN; exclude_prev = exclude_head; @@ -207,7 +207,7 @@ void parse_command_line(int argc, } else { while(NULL != exclude_prev->next) - exclude_prev=exclude_prev->next; + exclude_prev = exclude_prev->next; exclude_node->next = NULL; exclude_prev->next = exclude_node; @@ -215,14 +215,14 @@ void parse_command_line(int argc, break; case 'd': - opts->d=1; + opts->d = 1; if (check_d_input(opt_arg) == - 1) { HDprintf("<-d %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->delta = atof(opt_arg); + opts->delta = HDatof(opt_arg); /* -d 0 is the same as default */ if (H5_DBL_ABS_EQUAL(opts->delta, (double)0.0F)) @@ -230,13 +230,13 @@ void parse_command_line(int argc, break; case 'p': - opts->p=1; + opts->p = 1; if (check_p_input(opt_arg) == -1) { HDprintf("<-p %s> is not a valid option\n", opt_arg); usage(); h5diff_exit(EXIT_FAILURE); } - opts->percent = atof(opt_arg); + opts->percent = HDatof(opt_arg); /* -p 0 is the same as default */ if (H5_DBL_ABS_EQUAL(opts->percent, (double)0.0F)) @@ -244,7 +244,7 @@ void parse_command_line(int argc, break; case 'n': - opts->n=1; + opts->n = 1; if ( check_n_input(opt_arg) == -1) { HDprintf("<-n %s> is not a valid option\n", opt_arg); usage(); @@ -427,7 +427,7 @@ check_p_input( const char *str ) if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; - x = atof(str); + x = HDatof(str); if (x < 0) return -1; @@ -461,7 +461,7 @@ check_d_input( const char *str ) if (HDstrlen(str) > 2 && str[0] == '0' && str[1] == 'x') return -1; - x = atof(str); + x = HDatof(str); if (x < 0) return -1; diff --git a/tools/src/h5dump/h5dump_xml.c b/tools/src/h5dump/h5dump_xml.c index 5a5bb13..f599b7e 100644 --- a/tools/src/h5dump/h5dump_xml.c +++ b/tools/src/h5dump/h5dump_xml.c @@ -732,7 +732,7 @@ xml_escape_the_name(const char *str) * Programmer: REMcG *------------------------------------------------------------------------- */ -static char * +static char * xml_escape_the_string(const char *str, int slen) { size_t extra; @@ -794,18 +794,22 @@ xml_escape_the_string(const char *str, int slen) else if (*cp == '\'') { esc_len = HDstrlen(apos); HDstrncpy(ncp, apos, esc_len); + ncp[sizeof(ncp) - 1] = '\0'; } else if (*cp == '<') { esc_len = HDstrlen(lt); HDstrncpy(ncp, lt, esc_len); + ncp[sizeof(ncp) - 1] = '\0'; } else if (*cp == '>') { esc_len = HDstrlen(gt); HDstrncpy(ncp, gt, esc_len); + ncp[sizeof(ncp) - 1] = '\0'; } else if (*cp == '&') { esc_len = HDstrlen(amp); HDstrncpy(ncp, amp, esc_len); + ncp[sizeof(ncp) - 1] = '\0'; } else { *ncp = *cp; diff --git a/tools/src/h5jam/h5jam.c b/tools/src/h5jam/h5jam.c index 07797c8..009e527 100644 --- a/tools/src/h5jam/h5jam.c +++ b/tools/src/h5jam/h5jam.c @@ -148,7 +148,7 @@ parse_command_line (int argc, const char *argv[]) int opt = FALSE; /* parse command line options */ - while ((opt = get_option (argc, argv, s_opts, l_opts)) != EOF) + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char) opt) { diff --git a/tools/test/h5dump/CMakeLists.txt b/tools/test/h5dump/CMakeLists.txt index cfc542f..8a83699 100644 --- a/tools/test/h5dump/CMakeLists.txt +++ b/tools/test/h5dump/CMakeLists.txt @@ -35,7 +35,7 @@ endif () # -------------------------------------------------------------------- if (HDF5_BUILD_GENERATORS AND NOT ONLY_SHARED_LIBS) add_executable (h5dumpgentest ${HDF5_TOOLS_TEST_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) - target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5dumpgentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") TARGET_C_PROPERTIES (h5dumpgentest STATIC) target_link_libraries (h5dumpgentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) diff --git a/tools/test/h5dump/Makefile.am b/tools/test/h5dump/Makefile.am index a7a2bcb..21560fb 100644 --- a/tools/test/h5dump/Makefile.am +++ b/tools/test/h5dump/Makefile.am @@ -19,7 +19,7 @@ include $(top_srcdir)/config/commence.am # Include files in /src directory and /tools/lib directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib # Test programs and scripts TEST_PROG=h5dumpgentest diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index 3cfc14f..984eec8 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -22,7 +22,7 @@ */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" #include "h5tools.h" #define FILE1 "tgroup.h5" @@ -7207,19 +7207,43 @@ gent_dataset_idx(void) static void gent_packedbits(void) { - hid_t fid, dataset, space; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + fid = H5Fcreate(FILE66, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -7235,7 +7259,7 @@ gent_packedbits(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); H5Sclose(space); H5Dclose(dataset); @@ -7252,7 +7276,7 @@ gent_packedbits(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); H5Sclose(space); H5Dclose(dataset); @@ -7269,7 +7293,7 @@ gent_packedbits(void) valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); H5Sclose(space); H5Dclose(dataset); @@ -7286,7 +7310,7 @@ gent_packedbits(void) valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); H5Sclose(space); H5Dclose(dataset); @@ -7303,7 +7327,7 @@ gent_packedbits(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); H5Sclose(space); H5Dclose(dataset); @@ -7320,7 +7344,7 @@ gent_packedbits(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); H5Sclose(space); H5Dclose(dataset); @@ -7337,7 +7361,7 @@ gent_packedbits(void) val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); H5Sclose(space); H5Dclose(dataset); @@ -7354,7 +7378,7 @@ gent_packedbits(void) val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); H5Sclose(space); H5Dclose(dataset); @@ -7367,11 +7391,21 @@ gent_packedbits(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -7388,19 +7422,44 @@ gent_packedbits(void) static void gent_attr_intsize(void) { - hid_t fid, attr, space, root; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + fid = H5Fcreate(FILE69, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -7418,7 +7477,7 @@ gent_attr_intsize(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8); + H5Awrite(attr, H5T_NATIVE_UINT8, dsetu8[0]); H5Sclose(space); H5Aclose(attr); @@ -7436,7 +7495,7 @@ gent_attr_intsize(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16); + H5Awrite(attr, H5T_NATIVE_UINT16, dsetu16[0]); H5Sclose(space); H5Aclose(attr); @@ -7454,7 +7513,7 @@ gent_attr_intsize(void) valu32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32); + H5Awrite(attr, H5T_NATIVE_UINT32, dsetu32[0]); H5Sclose(space); H5Aclose(attr); @@ -7472,7 +7531,7 @@ gent_attr_intsize(void) valu64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64); + H5Awrite(attr, H5T_NATIVE_UINT64, dsetu64[0]); H5Sclose(space); H5Aclose(attr); @@ -7490,7 +7549,7 @@ gent_attr_intsize(void) val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT8, dset8); + H5Awrite(attr, H5T_NATIVE_INT8, dset8[0]); H5Sclose(space); H5Aclose(attr); @@ -7508,7 +7567,7 @@ gent_attr_intsize(void) val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, H5T_NATIVE_INT16, dset16); + H5Awrite(attr, H5T_NATIVE_INT16, dset16[0]); H5Sclose(space); H5Aclose(attr); @@ -7526,7 +7585,7 @@ gent_attr_intsize(void) val32bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT32, dset32); + H5Awrite(attr, H5T_NATIVE_INT32, dset32[0]); H5Sclose(space); H5Aclose(attr); @@ -7544,7 +7603,7 @@ gent_attr_intsize(void) val64bits <<= 1; } - H5Awrite(attr, H5T_NATIVE_INT64, dset64); + H5Awrite(attr, H5T_NATIVE_INT64, dset64[0]); H5Sclose(space); H5Aclose(attr); @@ -7557,13 +7616,23 @@ gent_attr_intsize(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl); + H5Awrite(attr, H5T_NATIVE_DOUBLE, dsetdbl[0]); H5Sclose(space); H5Aclose(attr); H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } static void @@ -8405,19 +8474,44 @@ static void gent_nested_compound_dt(void) { /* test nested data type */ static void gent_intscalars(void) { - hid_t fid, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE73, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -8435,7 +8529,7 @@ gent_intscalars(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); H5Sclose(space); H5Dclose(dataset); @@ -8454,7 +8548,7 @@ gent_intscalars(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); H5Sclose(space); H5Dclose(dataset); @@ -8473,7 +8567,7 @@ gent_intscalars(void) valu32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); H5Sclose(space); H5Dclose(dataset); @@ -8492,7 +8586,7 @@ gent_intscalars(void) valu64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); H5Sclose(space); H5Dclose(dataset); @@ -8511,7 +8605,7 @@ gent_intscalars(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); H5Sclose(space); H5Dclose(dataset); @@ -8530,7 +8624,7 @@ gent_intscalars(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); H5Sclose(space); H5Dclose(dataset); @@ -8549,7 +8643,7 @@ gent_intscalars(void) val32bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); H5Sclose(space); H5Dclose(dataset); @@ -8568,7 +8662,7 @@ gent_intscalars(void) val64bits <<= 1; } - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); H5Sclose(space); H5Dclose(dataset); @@ -8582,11 +8676,21 @@ gent_intscalars(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -8603,19 +8707,46 @@ gent_intscalars(void) static void gent_attr_intscalars(void) { - hid_t fid, attr, space, root, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t root = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE74, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); root = H5Gopen2(fid, "/", H5P_DEFAULT); @@ -8634,7 +8765,7 @@ gent_attr_intscalars(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Awrite(attr, tid, dsetu8); + H5Awrite(attr, tid, dsetu8[0]); H5Sclose(space); H5Aclose(attr); @@ -8653,7 +8784,7 @@ gent_attr_intscalars(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Awrite(attr, tid, dsetu16); + H5Awrite(attr, tid, dsetu16[0]); H5Sclose(space); H5Aclose(attr); @@ -8672,7 +8803,7 @@ gent_attr_intscalars(void) valu32bits <<= 1; } - H5Awrite(attr, tid, dsetu32); + H5Awrite(attr, tid, dsetu32[0]); H5Sclose(space); H5Aclose(attr); @@ -8691,7 +8822,7 @@ gent_attr_intscalars(void) valu64bits <<= 1; } - H5Awrite(attr, tid, dsetu64); + H5Awrite(attr, tid, dsetu64[0]); H5Sclose(space); H5Aclose(attr); @@ -8710,7 +8841,7 @@ gent_attr_intscalars(void) val8bits = (int8_t)(val8bits << 1); } - H5Awrite(attr, tid, dset8); + H5Awrite(attr, tid, dset8[0]); H5Sclose(space); H5Aclose(attr); @@ -8729,7 +8860,7 @@ gent_attr_intscalars(void) val16bits = (int16_t)(val16bits << 1); } - H5Awrite(attr, tid, dset16); + H5Awrite(attr, tid, dset16[0]); H5Sclose(space); H5Aclose(attr); @@ -8748,7 +8879,7 @@ gent_attr_intscalars(void) val32bits <<= 1; } - H5Awrite(attr, tid, dset32); + H5Awrite(attr, tid, dset32[0]); H5Sclose(space); H5Aclose(attr); @@ -8767,7 +8898,7 @@ gent_attr_intscalars(void) val64bits <<= 1; } - H5Awrite(attr, tid, dset64); + H5Awrite(attr, tid, dset64[0]); H5Sclose(space); H5Aclose(attr); @@ -8781,13 +8912,23 @@ gent_attr_intscalars(void) for(j = 0; j < dims[1]; j++) dsetdbl[i][j] = 0.0001F * (float)j + (float)i; - H5Awrite(attr, tid, dsetdbl); + H5Awrite(attr, tid, dsetdbl[0]); H5Sclose(space); H5Aclose(attr); H5Gclose(root); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -9342,19 +9483,45 @@ static void gent_compound_ints(void) { static void gent_intattrscalars(void) { - hid_t fid, attr, dataset, space, tid; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; hsize_t dims[2]; - uint8_t dsetu8[F73_XDIM][F73_YDIM8], valu8bits; - uint16_t dsetu16[F73_XDIM][F73_YDIM16], valu16bits; - uint32_t dsetu32[F73_XDIM][F73_YDIM32], valu32bits; - uint64_t dsetu64[F73_XDIM][F73_YDIM64], valu64bits; - int8_t dset8[F73_XDIM][F73_YDIM8], val8bits; - int16_t dset16[F73_XDIM][F73_YDIM16], val16bits; - int32_t dset32[F73_XDIM][F73_YDIM32], val32bits; - int64_t dset64[F73_XDIM][F73_YDIM64], val64bits; - double dsetdbl[F73_XDIM][F73_YDIM8]; + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F73_XDIM, F73_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F73_XDIM, F73_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F73_XDIM, F73_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F73_XDIM, F73_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F73_XDIM, F73_YDIM8); + fid = H5Fcreate(FILE78, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -9375,7 +9542,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); /* Attribute of 8 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu8); + H5Awrite(attr, tid, dsetu8[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9398,7 +9565,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); /* Attribute of 16 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu16); + H5Awrite(attr, tid, dsetu16[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9421,7 +9588,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); /* Attribute of 32 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu32); + H5Awrite(attr, tid, dsetu32[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9444,7 +9611,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); /* Attribute of 64 bits unsigned int */ attr = H5Acreate2(dataset, F73_DATASETU64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetu64); + H5Awrite(attr, tid, dsetu64[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9467,7 +9634,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); /* Attribute of 8 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS08, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset8); + H5Awrite(attr, tid, dset8[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9490,7 +9657,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); /* Attribute of 16 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS16, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset16); + H5Awrite(attr, tid, dset16[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9513,7 +9680,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); /* Attribute of 32 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS32, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset32); + H5Awrite(attr, tid, dset32[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9536,7 +9703,7 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); /* Attribute of 64 bits signed int */ attr = H5Acreate2(dataset, F73_DATASETS64, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dset64); + H5Awrite(attr, tid, dset64[0]); H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); @@ -9554,11 +9721,22 @@ gent_intattrscalars(void) H5Dwrite(dataset, tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); /* Attribute of double */ attr = H5Acreate2(dataset, F73_DUMMYDBL, tid, space, H5P_DEFAULT, H5P_DEFAULT); - H5Awrite(attr, tid, dsetdbl); + H5Awrite(attr, tid, dsetdbl[0]); + H5Aclose(attr); H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); } /*------------------------------------------------------------------------- @@ -9574,19 +9752,66 @@ gent_intattrscalars(void) static void gent_intsattrs(void) { - hid_t fid, attr, dataset, space, aspace; + hid_t fid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; hsize_t dims[2], adims[1]; - uint8_t dsetu8[F66_XDIM][F66_YDIM8], asetu8[F66_XDIM*F66_YDIM8], valu8bits; - uint16_t dsetu16[F66_XDIM][F66_YDIM16], asetu16[F66_XDIM*F66_YDIM16], valu16bits; - uint32_t dsetu32[F66_XDIM][F66_YDIM32], asetu32[F66_XDIM*F66_YDIM32], valu32bits; - uint64_t dsetu64[F66_XDIM][F66_YDIM64], asetu64[F66_XDIM*F66_YDIM64], valu64bits; - int8_t dset8[F66_XDIM][F66_YDIM8], aset8[F66_XDIM*F66_YDIM8], val8bits; - int16_t dset16[F66_XDIM][F66_YDIM16], aset16[F66_XDIM*F66_YDIM16], val16bits; - int32_t dset32[F66_XDIM][F66_YDIM32], aset32[F66_XDIM*F66_YDIM32], val32bits; - int64_t dset64[F66_XDIM][F66_YDIM64], aset64[F66_XDIM*F66_YDIM64], val64bits; - double dsetdbl[F66_XDIM][F66_YDIM8], asetdbl[F66_XDIM*F66_YDIM8]; + + + uint8_t **dsetu8 = NULL; + uint16_t **dsetu16 = NULL; + uint32_t **dsetu32 = NULL; + uint64_t **dsetu64 = NULL; + int8_t **dset8 = NULL; + int16_t **dset16 = NULL; + int32_t **dset32 = NULL; + int64_t **dset64 = NULL; + double **dsetdbl = NULL; + + uint8_t *asetu8 = NULL; + uint16_t *asetu16 = NULL; + uint32_t *asetu32 = NULL; + uint64_t *asetu64 = NULL; + int8_t *aset8 = NULL; + int16_t *aset16 = NULL; + int32_t *aset32 = NULL; + int64_t *aset64 = NULL; + double *asetdbl = NULL; + + uint8_t valu8bits; + uint16_t valu16bits; + uint32_t valu32bits; + uint64_t valu64bits; + int8_t val8bits; + int16_t val16bits; + int32_t val32bits; + int64_t val64bits; + unsigned int i, j; + /* Create arrays */ + H5TEST_ALLOCATE_2D_ARRAY(dsetu8, uint8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dsetu16, uint16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dsetu32, uint32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dsetu64, uint64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dset8, int8_t, F66_XDIM, F66_YDIM8); + H5TEST_ALLOCATE_2D_ARRAY(dset16, int16_t, F66_XDIM, F66_YDIM16); + H5TEST_ALLOCATE_2D_ARRAY(dset32, int32_t, F66_XDIM, F66_YDIM32); + H5TEST_ALLOCATE_2D_ARRAY(dset64, int64_t, F66_XDIM, F66_YDIM64); + H5TEST_ALLOCATE_2D_ARRAY(dsetdbl, double, F66_XDIM, F66_YDIM8); + + asetu8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(uint8_t)); + asetu16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(uint16_t)); + asetu32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(uint32_t)); + asetu64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(uint64_t)); + aset8 = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(int8_t)); + aset16 = HDcalloc(F66_XDIM * F66_YDIM16, sizeof(int16_t)); + aset32 = HDcalloc(F66_XDIM * F66_YDIM32, sizeof(int32_t)); + aset64 = HDcalloc(F66_XDIM * F66_YDIM64, sizeof(int64_t)); + asetdbl = HDcalloc(F66_XDIM * F66_YDIM8, sizeof(double)); + fid = H5Fcreate(FILE79, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); /* Dataset of 8 bits unsigned int */ @@ -9605,7 +9830,7 @@ gent_intsattrs(void) valu8bits = (uint8_t)(valu8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8); + H5Dwrite(dataset, H5T_NATIVE_UINT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu8[0]); /* Attribute of 8 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9632,7 +9857,7 @@ gent_intsattrs(void) valu16bits = (uint16_t)(valu16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16); + H5Dwrite(dataset, H5T_NATIVE_UINT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu16[0]); /* Attribute of 16 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -9659,7 +9884,7 @@ gent_intsattrs(void) valu32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32); + H5Dwrite(dataset, H5T_NATIVE_UINT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu32[0]); /* Attribute of 32 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -9686,7 +9911,7 @@ gent_intsattrs(void) valu64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64); + H5Dwrite(dataset, H5T_NATIVE_UINT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetu64[0]); /* Attribute of 64 bits unsigned int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -9713,7 +9938,7 @@ gent_intsattrs(void) val8bits = (int8_t)(val8bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8); + H5Dwrite(dataset, H5T_NATIVE_INT8, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset8[0]); /* Attribute of 8 bits signed int */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9740,7 +9965,7 @@ gent_intsattrs(void) val16bits = (int16_t)(val16bits << 1); } - H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + H5Dwrite(dataset, H5T_NATIVE_INT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16[0]); /* Attribute of 16 bits signed int */ adims[0] = F66_XDIM * F66_YDIM16; aspace = H5Screate_simple(1, adims, NULL); @@ -9767,7 +9992,7 @@ gent_intsattrs(void) val32bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32); + H5Dwrite(dataset, H5T_NATIVE_INT32, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset32[0]); /* Attribute of 32 bits signed int */ adims[0] = F66_XDIM * F66_YDIM32; aspace = H5Screate_simple(1, adims, NULL); @@ -9794,7 +10019,7 @@ gent_intsattrs(void) val64bits <<= 1; } - H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64); + H5Dwrite(dataset, H5T_NATIVE_INT64, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset64[0]); /* Attribute of 64 bits signed int */ adims[0] = F66_XDIM * F66_YDIM64; aspace = H5Screate_simple(1, adims, NULL); @@ -9816,7 +10041,7 @@ gent_intsattrs(void) asetdbl[i*dims[1]+j] = dsetdbl[i][j]; } - H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl); + H5Dwrite(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dsetdbl[0]); /* Attribute of double */ adims[0] = F66_XDIM * F66_YDIM8; aspace = H5Screate_simple(1, adims, NULL); @@ -9827,6 +10052,26 @@ gent_intsattrs(void) H5Sclose(space); H5Dclose(dataset); H5Fclose(fid); + + HDfree(dsetu8); + HDfree(dsetu16); + HDfree(dsetu32); + HDfree(dsetu64); + HDfree(dset8); + HDfree(dset16); + HDfree(dset32); + HDfree(dset64); + HDfree(dsetdbl); + + HDfree(asetu8); + HDfree(asetu16); + HDfree(asetu32); + HDfree(asetu64); + HDfree(aset8); + HDfree(aset16); + HDfree(aset32); + HDfree(aset64); + HDfree(asetdbl); } static void gent_bitnopaquefields(void) diff --git a/tools/test/h5import/h5importtest.c b/tools/test/h5import/h5importtest.c index 560f1b3..580530a 100644 --- a/tools/test/h5import/h5importtest.c +++ b/tools/test/h5import/h5importtest.c @@ -68,13 +68,12 @@ main(void) double rowi8 = 1.0F, coli8 = 2.0F, plni8 = 5.0F; /* Initialize machine endian */ - volatile uint32_t ibyte=0x01234567; + volatile uint32_t ibyte = 0x01234567; /* 0 for big endian, 1 for little endian. */ - if ((*((uint8_t*)(&ibyte))) == 0x67) - HDstrncpy(machine_order, "LE", 2); + if ((*((volatile uint8_t *)(&ibyte))) == 0x67) + HDstrcpy(machine_order, "LE"); else - HDstrncpy(machine_order, "BE", 2); - + HDstrcpy(machine_order, "BE"); /* * initialize the row, column, and plane vectors diff --git a/tools/test/h5repack/CMakeLists.txt b/tools/test/h5repack/CMakeLists.txt index 6f0b284..54cff64 100644 --- a/tools/test/h5repack/CMakeLists.txt +++ b/tools/test/h5repack/CMakeLists.txt @@ -28,7 +28,7 @@ set (REPACK_COMMON_SOURCES ) add_executable (h5repacktest ${REPACK_COMMON_SOURCES} ${HDF5_TOOLS_TEST_H5REPACK_SOURCE_DIR}/h5repacktst.c) target_include_directories (h5repacktest - PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" + PRIVATE "${HDF5_TOOLS_SRC_H5REPACK_SOURCE_DIR};${HDF5_TOOLS_DIR}/lib;${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>" ) if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5repacktest STATIC) diff --git a/tools/test/h5repack/h5repacktst.c b/tools/test/h5repack/h5repacktst.c index baac684..a39c048 100644 --- a/tools/test/h5repack/h5repacktst.c +++ b/tools/test/h5repack/h5repacktst.c @@ -2479,24 +2479,24 @@ int make_szip(hid_t loc_id) unsigned szip_pixels_per_block = 8; hsize_t dims[RANK] = {DIM1, DIM2}; hsize_t chunk_dims[RANK] = {CDIM1, CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + int **buf = NULL; int szip_can_encode = 0; - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); + /* create a space */ if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + goto error; /*------------------------------------------------------------------------- * SZIP @@ -2509,25 +2509,30 @@ int make_szip(hid_t loc_id) if (szip_can_encode) { /* set szip data */ if(H5Pset_szip (dcpl, szip_options_mask, szip_pixels_per_block) < 0) - goto out; - if (make_dset(loc_id, "dset_szip", sid, dcpl, buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_szip", sid, dcpl, buf[0]) < 0) + goto error; } else /* WARNING? SZIP is decoder only, can't generate test files */ if(H5Sclose(sid) < 0) - goto out; + goto error; if(H5Pclose(dcpl) < 0) - goto out; + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Sclose(sid); } H5E_END_TRY; + + HDfree(buf); + return -1; } #endif /* H5_HAVE_FILTER_SZIP */ @@ -2548,26 +2553,25 @@ int make_deflate(hid_t loc_id) hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK] = {DIM1,DIM2}; hsize_t chunk_dims[RANK] = {CDIM1,CDIM2}; - int buf[DIM1][DIM2]; + int **buf = NULL; hobj_ref_t bufref[1]; /* reference */ hsize_t dims1r[1] = {1}; - int i, j, n; - for (i = n = 0; i < DIM1; i++) { - for (j = 0; j < DIM2; j++) { - buf[i][j] = n++; - } - } + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); /* create a space */ if((sid = H5Screate_simple(RANK, dims, NULL)) < 0) - return -1; + goto error; /* create a dcpl */ if ((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) - goto out; + goto error; /* set up chunk */ if(H5Pset_chunk(dcpl, RANK, chunk_dims) < 0) - goto out; + goto error; /*------------------------------------------------------------------------- * GZIP @@ -2576,16 +2580,16 @@ int make_deflate(hid_t loc_id) #if defined (H5_HAVE_FILTER_DEFLATE) /* set deflate data */ if(H5Pset_deflate(dcpl, 9) < 0) - goto out; - if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf) < 0) - goto out; + goto error; + if (make_dset(loc_id, "dset_deflate", sid, dcpl, buf[0]) < 0) + goto error; /* create a reference to the dataset, test second seeep of file for references */ if (H5Rcreate(&bufref[0], loc_id, "dset_deflate", H5R_OBJECT, (hid_t)-1) < 0) - goto out; + goto error; if (write_dset(loc_id, 1, dims1r, "ref", H5T_STD_REF_OBJ, bufref) < 0) - goto out; + goto error; #endif @@ -2594,17 +2598,22 @@ int make_deflate(hid_t loc_id) *------------------------------------------------------------------------- */ if(H5Sclose(sid) < 0) - goto out; + goto error; if(H5Pclose(dcpl) < 0) - goto out; + goto error; + + HDfree(buf); return 0; -out: +error: H5E_BEGIN_TRY { H5Pclose(dcpl); H5Sclose(sid); } H5E_END_TRY; + + HDfree(buf); + return -1; } @@ -2619,29 +2628,27 @@ out: static int make_shuffle(hid_t loc_id) { - hid_t dcpl; /* dataset creation property list */ - hid_t sid; /* dataspace ID */ + hid_t dcpl = H5I_INVALID_HID; /* dataset creation property list */ + hid_t sid = H5I_INVALID_HID; /* dataspace ID */ hsize_t dims[RANK]={DIM1,DIM2}; hsize_t chunk_dims[RANK]={CDIM1,CDIM2}; - int buf[DIM1][DIM2]; - int i, j, n; + int **buf = NULL; + + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, DIM1, DIM2); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, DIM1, DIM2); - for (i=n=0; i) add_executable (h5clear_gentest ${HDF5_TOOLS_TEST_MISC_SOURCE_DIR}/h5clear_gentest.c) - target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") + target_include_directories (h5clear_gentest PRIVATE "${HDF5_SRC_DIR};${HDF5_TEST_SRC_DIR};${HDF5_BINARY_DIR};$<$:${MPI_C_INCLUDE_DIRS}>") if (NOT ONLY_SHARED_LIBS) TARGET_C_PROPERTIES (h5clear_gentest STATIC) target_link_libraries (h5clear_gentest PRIVATE ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) diff --git a/tools/test/misc/Makefile.am b/tools/test/misc/Makefile.am index f2d2489..c58ba38 100644 --- a/tools/test/misc/Makefile.am +++ b/tools/test/misc/Makefile.am @@ -21,7 +21,7 @@ include $(top_srcdir)/config/commence.am SUBDIRS=vds # Include src directory -AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib +AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/test -I$(top_srcdir)/tools/lib #test scripts and programs TEST_PROG=h5repart_gentest h5clear_gentest talign diff --git a/tools/test/misc/h5clear_gentest.c b/tools/test/misc/h5clear_gentest.c index d5f415e..06ba473 100644 --- a/tools/test/misc/h5clear_gentest.c +++ b/tools/test/misc/h5clear_gentest.c @@ -11,7 +11,7 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "hdf5.h" -#include "H5private.h" +#include "h5test.h" /* The HDF5 test files */ const char *FILENAME[] = { @@ -62,13 +62,18 @@ gen_cache_image_file(const char *fname) hid_t dcpl = H5I_INVALID_HID; /* Dataset creation property list */ hsize_t dims[2]; /* Dimension sizes */ hsize_t chunks[2]; /* Chunked dimension sizes */ - int buf[50][100]; /* Buffer for data to write */ - int i, j; /* Local index variables */ + int **buf = NULL; /* Buffer for data to write */ H5AC_cache_image_config_t cache_image_config = /* Cache image input configuration */ { H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION, TRUE, FALSE, H5AC__CACHE_IMAGE__ENTRY_AGEOUT__NONE}; + /* Create and fill array */ + H5TEST_ALLOCATE_2D_ARRAY(buf, int, 50, 100); + if (NULL == buf) + goto error; + H5TEST_FILL_2D_ARRAY(buf, int, 50, 100); + /* Create a copy of file access property list */ if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) goto error; @@ -91,11 +96,6 @@ gen_cache_image_file(const char *fname) if((sid = H5Screate_simple(2, dims, NULL)) < 0) goto error; - /* Initialize buffer for writing to dataset */ - for(i = 0; i < 50; i++) - for(j = 0; j < 100; j++) - buf[i][j] = i * j; - /* Set up to create a chunked dataset */ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error; @@ -107,7 +107,7 @@ gen_cache_image_file(const char *fname) goto error; /* Write to the dataset */ - if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) + if(H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0) goto error; /* Closing */ @@ -121,6 +121,9 @@ gen_cache_image_file(const char *fname) goto error; if(H5Fclose(fid) < 0) goto error; + + HDfree(buf); + return 0; error: @@ -132,6 +135,9 @@ error: H5Pclose(fapl); H5Pclose(dcpl); } H5E_END_TRY; + + HDfree(buf); + return 1; } /* gen_cache_image_file() */ diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c index 8146d84..044ce0c 100644 --- a/tools/test/perform/pio_perf.c +++ b/tools/test/perform/pio_perf.c @@ -300,7 +300,7 @@ typedef struct _minmax { /* local functions */ static off_t parse_size_directive(const char *size); -static struct options *parse_command_line(int argc, char *argv[]); +static struct options *parse_command_line(int argc, const char *argv[]); static void run_test_loop(struct options *options); static int run_test(iotype iot, parameters parms, struct options *opts); static void output_all_info(minmax *mm, int count, int indent_level); @@ -327,7 +327,7 @@ static off_t squareo(off_t); * Modifications: */ int -main(int argc, char **argv) +main(int argc, const char *argv[]) { int ret; int exit_value = EXIT_SUCCESS; @@ -1262,7 +1262,7 @@ report_parameters(struct options *opts) * Added 2D testing (Christian Chilan, 10. August 2005) */ static struct options * -parse_command_line(int argc, char *argv[]) +parse_command_line(int argc, const char *argv[]) { register int opt; struct options *cl_opts; @@ -1291,7 +1291,7 @@ parse_command_line(int argc, char *argv[]) cl_opts->h5_write_only = FALSE; /* Do both read and write by default */ cl_opts->verify = FALSE; /* No Verify data correctness by default */ - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'a': cl_opts->h5_alignment = parse_size_directive(opt_arg); diff --git a/tools/test/perform/sio_perf.c b/tools/test/perform/sio_perf.c index a56558e..d2eb3fc 100644 --- a/tools/test/perform/sio_perf.c +++ b/tools/test/perform/sio_perf.c @@ -303,7 +303,7 @@ typedef struct _minmax { /* local functions */ static hsize_t parse_size_directive(const char *size); -static struct options *parse_command_line(int argc, char *argv[]); +static struct options *parse_command_line(int argc, const char *argv[]); static void run_test_loop(struct options *options); static int run_test(iotype iot, parameters parms, struct options *opts); static void output_all_info(minmax *mm, int count, int indent_level); @@ -324,7 +324,7 @@ static void report_parameters(struct options *opts); * Modifications: */ int -main(int argc, char **argv) +main(int argc, const char *argv[]) { int exit_value = EXIT_SUCCESS; struct options *opts = NULL; @@ -944,7 +944,7 @@ report_parameters(struct options *opts) * Added multidimensional testing (Christian Chilan, April, 2008) */ static struct options * -parse_command_line(int argc, char *argv[]) +parse_command_line(int argc, const char *argv[]) { int opt; struct options *cl_opts; @@ -984,7 +984,7 @@ parse_command_line(int argc, char *argv[]) cl_opts->h5_extendable = FALSE; /* Use extendable dataset */ cl_opts->verify = FALSE; /* No Verify data correctness by default */ - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) != EOF) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { case 'a': cl_opts->h5_alignment = parse_size_directive(opt_arg); diff --git a/tools/test/perform/zip_perf.c b/tools/test/perform/zip_perf.c index e301bb3..8f1f584 100644 --- a/tools/test/perform/zip_perf.c +++ b/tools/test/perform/zip_perf.c @@ -552,7 +552,7 @@ do_write_test(unsigned long file_size, unsigned long min_buf_size, * Modifications: */ int -main(int argc, char **argv) +main(int argc, const char *argv[]) { unsigned long min_buf_size = 128 * ONE_KB, max_buf_size = ONE_MB; unsigned long file_size = 64 * ONE_MB; @@ -563,7 +563,7 @@ main(int argc, char **argv) /* Initialize h5tools lib */ h5tools_init(); - while ((opt = get_option(argc, (const char **)argv, s_opts, l_opts)) > 0) { + while ((opt = get_option(argc, argv, s_opts, l_opts)) > 0) { switch ((char)opt) { case '0': case '1': case '2': case '3': case '4': case '5': -- cgit v0.12