From e8c8c29342df3213795bcdfd78f203510ba69362 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Mon, 30 Sep 2019 14:56:30 -0500 Subject: fix for statement declare variable --- src/H5FDhdfs.c | 63 ++++++++++++++------------- src/H5FDros3.c | 53 ++++++++++++----------- test/external.c | 89 ++++++++++++++++++++++++++++---------- tools/libtest/h5tools_test_utils.c | 3 +- 4 files changed, 126 insertions(+), 82 deletions(-) diff --git a/src/H5FDhdfs.c b/src/H5FDhdfs.c index 83d0202..819d200 100644 --- a/src/H5FDhdfs.c +++ b/src/H5FDhdfs.c @@ -64,7 +64,7 @@ static hid_t H5FD_HDFS_g = 0; #define HDFS_STATS_START_POWER 10 #define HDFS_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. @@ -87,7 +87,7 @@ static hid_t H5FD_HDFS_g = 0; /* array to hold pre-computed boundaries for stats bins */ static unsigned long long hdfs_stats_boundaries[HDFS_STATS_BIN_COUNT]; - + /*************************************************************************** * * Structure: hdfs_statsbin @@ -137,7 +137,7 @@ typedef struct { */ #define HDFS_HDFST_MAGIC 0x1AD5DE84 - + /*************************************************************************** * * Structure: hdfs_t @@ -186,7 +186,7 @@ typedef struct { hdfsFile file; } hdfs_t; - + /*-------------------------------------------------------------------------- * Function: H5FD_hdfs_handle_open * @@ -313,7 +313,7 @@ done: } /* H5FD_hdfs_handle_open() */ - + /*-------------------------------------------------------------------------- * Function: H5FD_hdfs_handle_close * @@ -375,7 +375,7 @@ done: #endif /* H5_HAVE_LIBHDFS */ - + /*************************************************************************** * * Structure: H5FD_hdfs_t @@ -529,7 +529,7 @@ static const H5FD_class_t H5FD_hdfs_g = { H5FL_DEFINE_STATIC(H5FD_hdfs_t); #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -559,7 +559,7 @@ done: } /* H5FD__init_package() */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_init * @@ -581,6 +581,7 @@ hid_t H5FD_hdfs_init(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ + unsigned int bin_i; FUNC_ENTER_NOAPI(FAIL) @@ -598,7 +599,7 @@ H5FD_hdfs_init(void) #if HDFS_STATS /* pre-compute statsbin boundaries */ - for (unsigned bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { + for (bin_i = 0; bin_i < HDFS_STATS_BIN_COUNT; bin_i++) { unsigned long long value = 0; HDFS_STATS_POW(bin_i, &value) hdfs_stats_boundaries[bin_i] = value; @@ -612,7 +613,7 @@ done: } /* end H5FD_hdfs_init() */ - + /*--------------------------------------------------------------------------- * Function: H5FD_hdfs_term * @@ -643,7 +644,7 @@ H5FD_hdfs_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_hdfs_term() */ - + /*------------------------------------------------------------------------- * Function: H5Pset_fapl_hdfs * @@ -696,7 +697,7 @@ done: } /* H5Pset_fapl_hdfs() */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_validate_config() * @@ -747,7 +748,7 @@ done: } /* H5FD_hdfs_validate_config() */ - + /*------------------------------------------------------------------------- * Function: H5Pget_fapl_hdfs * @@ -808,7 +809,7 @@ done: } /* H5Pget_fapl_hdfs() */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_get * @@ -855,7 +856,7 @@ done: } /* H5FD_hdfs_fapl_get() */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_copy * @@ -899,7 +900,7 @@ done: } /* H5FD_hdfs_fapl_copy() */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_fapl_free * @@ -930,7 +931,7 @@ H5FD_hdfs_fapl_free(void *_fa) } /* H5FD_hdfs_fapl_free() */ #if HDFS_STATS - + /*---------------------------------------------------------------------------- * * Function: hdfs_reset_stats() @@ -989,7 +990,7 @@ done: } /* hdfs_reset_stats */ #endif /* HDFS_STATS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_open() @@ -1138,7 +1139,7 @@ done: #endif /* H5_HAVE_LIBHDFS */ #if HDFS_STATS - + /*---------------------------------------------------------------------------- * * Function: hdfs_fprint_stats() @@ -1425,7 +1426,7 @@ done: } /* hdfs_fprint_stats */ #endif /* HDFS_STATS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_close() @@ -1508,7 +1509,7 @@ done: #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_cmp() @@ -1592,7 +1593,7 @@ H5FD_hdfs_cmp( #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * Function: H5FD_hdfs_query * @@ -1631,7 +1632,7 @@ H5FD_hdfs_query( FUNC_LEAVE_NOAPI(SUCCEED) } /* H5FD_hdfs_query() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_eoa() @@ -1689,7 +1690,7 @@ H5FD_hdfs_get_eoa( #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_set_eoa() @@ -1749,7 +1750,7 @@ H5FD_hdfs_set_eoa( #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_eof() @@ -1807,7 +1808,7 @@ H5FD_hdfs_get_eof( #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_get_handle() @@ -1880,7 +1881,7 @@ done: #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_read() @@ -2014,7 +2015,7 @@ done: #endif /* H5_HAVE_LIBHDFS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_write() @@ -2059,7 +2060,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5FD_hdfs_write() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_truncate() @@ -2103,7 +2104,7 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5FD_hdfs_truncate() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_lock() @@ -2136,7 +2137,7 @@ H5FD_hdfs_lock( FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5FD_hdfs_lock() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_hdfs_unlock() diff --git a/src/H5FDros3.c b/src/H5FDros3.c index a369ca2..75fcfd7 100644 --- a/src/H5FDros3.c +++ b/src/H5FDros3.c @@ -68,7 +68,7 @@ static hid_t H5FD_ROS3_g = 0; #define ROS3_STATS_START_POWER 10 #define ROS3_STATS_BIN_COUNT 16 /* MUST BE GREATER THAN 0 */ - + /* * Calculate `BASE ^ (START_POWER + (INTERVAL * bin_i))` * Stores result at `(unsigned long long *) out_ptr`. @@ -278,7 +278,7 @@ static const H5FD_class_t H5FD_ros3_g = { /* Declare a free list to manage the H5FD_ros3_t struct */ H5FL_DEFINE_STATIC(H5FD_ros3_t); - + /*------------------------------------------------------------------------- * Function: H5FD__init_package * @@ -307,7 +307,7 @@ done: } /* end H5FD__init_package() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_init * @@ -325,6 +325,7 @@ hid_t H5FD_ros3_init(void) { hid_t ret_value = H5I_INVALID_HID; + unsigned int bin_i; FUNC_ENTER_NOAPI(FAIL) @@ -338,7 +339,7 @@ H5FD_ros3_init(void) #if ROS3_STATS /* pre-compute statsbin boundaries */ - for (unsigned bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { + for (bin_i = 0; bin_i < ROS3_STATS_BIN_COUNT; bin_i++) { unsigned long long value = 0; ROS3_STATS_POW(bin_i, &value) ros3_stats_boundaries[bin_i] = value; @@ -353,7 +354,7 @@ done: } /* end H5FD_ros3_init() */ - + /*--------------------------------------------------------------------------- * Function: H5FD_ros3_term * @@ -381,7 +382,7 @@ H5FD_ros3_term(void) } /* end H5FD_ros3_term() */ - + /*------------------------------------------------------------------------- * Function: H5Pset_fapl_ros3 * @@ -430,7 +431,7 @@ done: } /* end H5Pset_fapl_ros3() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_validate_config() * @@ -481,7 +482,7 @@ done: } /* end H5FD_ros3_validate_config() */ - + /*------------------------------------------------------------------------- * Function: H5Pget_fapl_ros3 * @@ -540,7 +541,7 @@ done: } /* end H5Pget_fapl_ros3() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_get * @@ -589,7 +590,7 @@ done: } /* end H5FD_ros3_fapl_get() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_copy * @@ -634,7 +635,7 @@ done: } /* end H5FD_ros3_fapl_copy() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_fapl_free * @@ -665,7 +666,7 @@ H5FD_ros3_fapl_free(void *_fa) } /* end H5FD_ros3_fapl_free() */ #if ROS3_STATS - + /*---------------------------------------------------------------------------- * * Function: ros3_reset_stats() @@ -723,7 +724,7 @@ done: #endif /* ROS3_STATS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_open() @@ -880,7 +881,7 @@ done: } /* end H5FD_ros3_open() */ #if ROS3_STATS - + /*---------------------------------------------------------------------------- * * Function: ros3_fprint_stats() @@ -1169,7 +1170,7 @@ done: } /* ros3_fprint_stats */ #endif /* ROS3_STATS */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_close() @@ -1230,7 +1231,7 @@ done: } /* end H5FD_ros3_close() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_cmp() @@ -1395,7 +1396,7 @@ done: } /* H5FD_ros3_cmp() */ - + /*------------------------------------------------------------------------- * Function: H5FD_ros3_query * @@ -1436,7 +1437,7 @@ H5FD_ros3_query(const H5FD_t H5_ATTR_UNUSED *_file, } /* H5FD_ros3_query() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_eoa() @@ -1472,7 +1473,7 @@ H5FD_ros3_get_eoa(const H5FD_t *_file, } /* end H5FD_ros3_get_eoa() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_set_eoa() @@ -1509,7 +1510,7 @@ H5FD_ros3_set_eoa(H5FD_t *_file, } /* H5FD_ros3_set_eoa() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_eof() @@ -1544,7 +1545,7 @@ H5FD_ros3_get_eof(const H5FD_t *_file, } /* end H5FD_ros3_get_eof() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_get_handle() @@ -1587,7 +1588,7 @@ done: } /* end H5FD_ros3_get_handle() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_read() @@ -1685,7 +1686,7 @@ done: } /* end H5FD_ros3_read() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_write() @@ -1728,7 +1729,7 @@ done: } /* H5FD_ros3_write() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_truncate() @@ -1770,7 +1771,7 @@ done: } /* end H5FD_ros3_truncate() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_lock() @@ -1801,7 +1802,7 @@ H5FD_ros3_lock(H5FD_t H5_ATTR_UNUSED *_file, } /* end H5FD_ros3_lock() */ - + /*------------------------------------------------------------------------- * * Function: H5FD_ros3_unlock() diff --git a/test/external.c b/test/external.c index e2565de..4d9fef0 100644 --- a/test/external.c +++ b/test/external.c @@ -20,6 +20,9 @@ #include "external_common.h" #include "external_fname.h" +#define AEF_EXNAME_MAX_LEN 12 /* string buffer size for external file name */ + /* used in __add_external_files() */ + /*------------------------------------------------------------------------- * Function: files_have_same_contents @@ -432,6 +435,56 @@ test_unlimited(hid_t file) /*------------------------------------------------------------------------- + * Function: __add_external_files + * + * Purpose: Add external file names to the DCPL with the given properties. + * Used in test_multiple_files(). + * Limit to no more than 999 external files. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jacob Smith + * 29 Sep 2019 + * + *------------------------------------------------------------------------- + */ +static int +__add_external_files( + hid_t dcpl_id, + unsigned int n_external_files, + off_t offset, + hsize_t max_ext_size) +{ + char exname[AEF_EXNAME_MAX_LEN+1]; + unsigned int i = 0; + + if (dcpl_id < 0) { + return -1; + } + for (i = 0; i < n_external_files; i++) { + if (HDsnprintf( + exname, + AEF_EXNAME_MAX_LEN, + "ext%d.data", + i+1) + > AEF_EXNAME_MAX_LEN) + { + HDfprintf(stderr, "External file %d overflows name buffer\n", i+1); + fflush(stderr); + return -1; + } + if (H5Pset_external(dcpl_id, exname, offset, max_ext_size) < 0) { + HDfprintf(stderr, "Problem adding external file %s\n", exname); + fflush(stderr); + return -1; + } + } + return 0; +} /* end __add_external_files() */ + + +/*------------------------------------------------------------------------- * Function: test_multiple_files * * Purpose: Test multiple external files for a dataset. @@ -447,13 +500,13 @@ test_unlimited(hid_t file) static int test_multiple_files(hid_t file) { - hid_t dcpl = -1; /* dataset creation properties */ - hid_t space = -1; /* dataspace */ - hid_t dset = -1; /* dataset */ - hsize_t cur_size[1] = {100}; /* data space current size */ - hsize_t max_size[1] = {100}; /* data space maximum size */ - hsize_t max_ext_size; /* maximum size of external files */ - unsigned n_external_files = 4; + hid_t dcpl = -1; /* dataset creation properties */ + hid_t space = -1; /* dataspace */ + hid_t dset = -1; /* dataset */ + hsize_t cur_size[1] = {100}; /* data space current size */ + hsize_t max_size[1] = {100}; /* data space maximum size */ + hsize_t max_ext_size; /* maximum size of external files */ + unsigned int n_external_files = 4; TESTING("multiple external files"); @@ -462,14 +515,8 @@ test_multiple_files(hid_t file) max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files); - for (unsigned i = 0; i < n_external_files; i++) { - char exname[9] = ""; - HDsnprintf(exname, 9, "ext%d.data", i+1); - if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) { - HDfprintf(stderr, "Problem adding external file %s\n", exname); - fflush(stderr); - FAIL_STACK_ERROR - } + if (__add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) { + FAIL_STACK_ERROR; } if((space = H5Screate_simple(1, cur_size, max_size)) < 0) @@ -490,15 +537,9 @@ test_multiple_files(hid_t file) max_ext_size -= 1; - for (unsigned i = 0; i < n_external_files; i++) { - char exname[9] = ""; - HDsnprintf(exname, 9, "ext%d.data", i+1); - if (H5Pset_external(dcpl, exname, (off_t)0, max_ext_size) < 0) { - HDfprintf(stderr, "Problem adding external file %s\n", exname); - fflush(stderr); - FAIL_STACK_ERROR - } - } /* end for each external file */ + if (__add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) { + FAIL_STACK_ERROR; + } H5E_BEGIN_TRY { dset = H5Dcreate2(file, "dset7", H5T_NATIVE_INT, space, H5P_DEFAULT, dcpl, H5P_DEFAULT); diff --git a/tools/libtest/h5tools_test_utils.c b/tools/libtest/h5tools_test_utils.c index 7908519..120f803 100644 --- a/tools/libtest/h5tools_test_utils.c +++ b/tools/libtest/h5tools_test_utils.c @@ -1134,6 +1134,7 @@ test_set_configured_fapl(void) #endif /* H5_HAVE_LIBHDFS */ }; /* testcases `cases` array */ + unsigned int i; #ifdef H5_HAVE_ROS3_VFD n_cases += 5; @@ -1145,7 +1146,7 @@ test_set_configured_fapl(void) TESTING("programmatic fapl set"); - for (unsigned i = 0; i < n_cases; i++) { + for (i = 0; i < n_cases; i++) { int result; testcase C = cases[i]; -- cgit v0.12