diff options
Diffstat (limited to 'c++/test/titerate.cpp')
-rw-r--r-- | c++/test/titerate.cpp | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp index 17620ca..b6a9436 100644 --- a/c++/test/titerate.cpp +++ b/c++/test/titerate.cpp @@ -67,7 +67,8 @@ typedef struct { iter_enum command; /* The type of return value */ } iter_info; -int iter_strcmp(const void *s1, const void *s2); +static int iter_strcmp(const void *s1, const void *s2); +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname); /*------------------------------------------------------------------------- * Function: iter_strcmp @@ -75,10 +76,10 @@ int iter_strcmp(const void *s1, const void *s2); * Purpose String comparison routine for qsort *------------------------------------------------------------------------- */ -int +static int iter_strcmp(const void *s1, const void *s2) { - return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2)); + return (HDstrcmp(*reinterpret_cast<const char *const *>(s1), *reinterpret_cast<const char *const *>(s2))); } /*------------------------------------------------------------------------- @@ -91,7 +92,7 @@ static herr_t liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info, void *op_data) { - iter_info *info = (iter_info *)op_data; + iter_info *info = static_cast<iter_info *>(op_data); static int count = 0; static int count2 = 0; @@ -133,7 +134,6 @@ liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR static void test_iter_group(FileAccPropList &fapl) { - int i; /* counting variable */ hsize_t idx; /* Index in the group */ char name[NAMELEN]; /* temporary name buffer */ char * lnames[NDATASETS + 2]; /* Names of the links created */ @@ -159,7 +159,7 @@ test_iter_group(FileAccPropList &fapl) // Create a scalar file space DataSpace filespace; - for (i = 0; i < NDATASETS; i++) { + for (int i = 0; i < NDATASETS; i++) { sprintf(name, "Dataset %d", i); // Create a dataset in the file @@ -168,8 +168,7 @@ test_iter_group(FileAccPropList &fapl) /* Keep a copy of the dataset names */ lnames[i] = HDstrdup(name); check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__); - - } /* end for */ + } /* Create a group and named datatype under root group for testing */ Group grp(file.createGroup(GROUP1, 0)); @@ -181,7 +180,7 @@ test_iter_group(FileAccPropList &fapl) check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__); /* Sort the dataset names */ - HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp); + HDqsort(lnames, NDATASETS + 2, sizeof(char *), iter_strcmp); /* Iterate through the datasets in the root group in various ways */ @@ -193,10 +192,10 @@ test_iter_group(FileAccPropList &fapl) // Get the number of object in the root group hsize_t nobjs = root_group.getNumObjs(); - verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__); + verify_val(static_cast<long>(nobjs), NDATASETS + 2, "H5Gget_info", __LINE__, __FILE__); H5std_string obj_name; - for (i = 0; i < nobjs; i++) { + for (hsize_t i = 0; i < nobjs; i++) { // H5O_info2_t oinfo; /* Object info */ obj_name = root_group.getObjnameByIdx(i); @@ -206,7 +205,7 @@ test_iter_group(FileAccPropList &fapl) // oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, "."); // ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo, // H5P_DEFAULT); - } /* end for */ + } // Attempted to iterate with invalid index, should fail try { @@ -222,7 +221,7 @@ test_iter_group(FileAccPropList &fapl) // Attempted to iterate with negative index, should fail try { info.command = RET_ZERO; - idx = (hsize_t)-1; + idx = HSIZE_UNDEF; obj_name = root_group.getObjnameByIdx(idx); // Should FAIL but didn't, so throw an invalid action exception @@ -268,7 +267,7 @@ test_iter_group(FileAccPropList &fapl) } // do nothing, exception expected /* Free the dataset names */ - for (i = 0; i < (NDATASETS + 2); i++) + for (int i = 0; i < NDATASETS + 2; i++) HDfree(lnames[i]); // Everything will be closed as they go out of scope @@ -360,7 +359,7 @@ const H5std_string ATTR_NAME("Units"); const H5std_string FATTR_NAME("F attr"); const H5std_string GATTR_NAME("G attr"); const int DIM1 = 2; -void +static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname) { try { |