summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-03-10 18:41:34 (GMT)
committerGitHub <noreply@github.com>2021-03-10 18:41:34 (GMT)
commita7a013782f0af93f511142b5d167c2bc8ca8505d (patch)
tree5c13dc35b15c30315bcae04aa6971d73acabd9fc /test
parent7501f96ab9605e11c58bc0c9e6412e4db30ba7db (diff)
downloadhdf5-a7a013782f0af93f511142b5d167c2bc8ca8505d.zip
hdf5-a7a013782f0af93f511142b5d167c2bc8ca8505d.tar.gz
hdf5-a7a013782f0af93f511142b5d167c2bc8ca8505d.tar.bz2
Various clang tidy warning fixes (#448)
* Fixed clang-tidy bugprone-reserved-identifier warnings * Fixed clang-tidy bugprone-assert-side-effect warnings * Fixed clang-tidy bugprone-copy-constructor-init warning * Fixed clang-tidy readability-redundant-preprocessor warning For error_test.c the removed code was already dead, because it was in the else of an `#if H5_USE_16_API` block. Based on H5Location.h, I think p_get_ref_obj_type was meant to be in `#ifndef DOXYGEN_SHOULD_SKIP_THIS` and an `#endif` was missing. Similarly, in the header, getObjTypeByIdx is only in H5_NO_DEPRECATED_SYMBOLS, not DOXYGEN_SHOULD_SKIP_THIS. * Fixed clang-tidy readability-redundant-string-init warnings * Fixed some clang-tidy performance-type-promotion-in-math-fn warnings * Fixed clang-tidy performance-unnecessary-value-param warnings * Reformat source with clang v10.0.1. Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
Diffstat (limited to 'test')
-rw-r--r--test/cache_common.c4
-rw-r--r--test/dsets.c38
-rw-r--r--test/earray.c50
-rw-r--r--test/error_test.c5
-rw-r--r--test/external.c6
-rw-r--r--test/ohdr.c6
6 files changed, 52 insertions, 57 deletions
diff --git a/test/cache_common.c b/test/cache_common.c
index 54b1cc5..676b8d1 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -1683,7 +1683,7 @@ execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr, struct flush_o
HDassert(cache_ptr != NULL);
HDassert(cache_ptr->magic == H5C__H5C_T_MAGIC);
HDassert(entry_ptr != NULL);
- HDassert(entry_ptr = entry_ptr->self);
+ HDassert(entry_ptr == entry_ptr->self);
HDassert(entry_ptr->header.addr == entry_ptr->addr);
HDassert((entry_ptr->flush_op_self_resize_in_progress) || (entry_ptr->header.size == entry_ptr->size));
HDassert(op_ptr != NULL);
@@ -2243,7 +2243,7 @@ resize_entry(H5F_t *file_ptr, int32_t type, int32_t idx, size_t new_size, hbool_
}
else {
- HDassert(entry_ptr->size = (entry_ptr->header).size);
+ HDassert(entry_ptr->size == (entry_ptr->header).size);
}
}
}
diff --git a/test/dsets.c b/test/dsets.c
index 8600d75..0905b4e 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -3181,7 +3181,7 @@ test_nbit_int(hid_t file)
/* Initialize data, assuming size of long long >= size of int */
for (i = 0; i < (size_t)size[0]; i++)
for (j = 0; j < (size_t)size[1]; j++) {
- power = HDpow(2.0f, (double)(precision - 1));
+ power = HDpow(2.0, (double)(precision - 1));
orig_data[i][j] = (int)(((long long)HDrandom() % (long long)power) << offset);
/* even-numbered values are negtive */
@@ -3558,7 +3558,7 @@ test_nbit_array(hid_t file)
for (j = 0; j < (size_t)size[1]; j++)
for (m = 0; m < (size_t)adims[0]; m++)
for (n = 0; n < (size_t)adims[1]; n++) {
- power = HDpow(2.0F, (double)precision);
+ power = HDpow(2.0, (double)precision);
orig_data[i][j][m][n] =
(unsigned int)(((long long)HDrandom() % (long long)power) << offset);
} /* end for */
@@ -3754,11 +3754,11 @@ test_nbit_compound(hid_t file)
/* Initialize data, assuming size of long long >= size of member datatypes */
for (i = 0; i < (size_t)size[0]; i++)
for (j = 0; j < (size_t)size[1]; j++) {
- power = HDpow(2.0F, (double)(precision[0] - 1));
+ power = HDpow(2.0, (double)(precision[0] - 1));
orig_data[i][j].i = (int)(((long long)HDrandom() % (long long)power) << offset[0]);
- power = HDpow(2.0F, (double)(precision[1] - 1));
+ power = HDpow(2.0, (double)(precision[1] - 1));
orig_data[i][j].c = (char)(((long long)HDrandom() % (long long)power) << offset[1]);
- power = HDpow(2.0F, (double)(precision[2] - 1));
+ power = HDpow(2.0, (double)(precision[2] - 1));
orig_data[i][j].s = (short)(((long long)HDrandom() % (long long)power) << offset[2]);
orig_data[i][j].f = float_val[i][j];
@@ -4036,32 +4036,32 @@ test_nbit_compound_2(hid_t file)
/* Initialize data, assuming size of long long >= size of member datatypes */
for (i = 0; i < (size_t)size[0]; i++)
for (j = 0; j < (size_t)size[1]; j++) {
- power = HDpow(2.0F, (double)(precision[0] - 1));
+ power = HDpow(2.0, (double)(precision[0] - 1));
orig_data[i][j].a.i = (int)(((long long)HDrandom() % (long long)power) << offset[0]);
- power = HDpow(2.0F, (double)(precision[1] - 1));
+ power = HDpow(2.0, (double)(precision[1] - 1));
orig_data[i][j].a.c = (char)(((long long)HDrandom() % (long long)power) << offset[1]);
- power = HDpow(2.0F, (double)(precision[2] - 1));
+ power = HDpow(2.0, (double)(precision[2] - 1));
orig_data[i][j].a.s = (short)(-(((long long)HDrandom() % (long long)power) << offset[2]));
orig_data[i][j].a.f = float_val[i][j];
- power = HDpow(2.0F, (double)precision[3]);
+ power = HDpow(2.0, (double)precision[3]);
orig_data[i][j].v = (unsigned int)(((long long)HDrandom() % (long long)power) << offset[3]);
for (m = 0; m < (size_t)array_dims[0]; m++)
for (n = 0; n < (size_t)array_dims[1]; n++) {
- power = HDpow(2.0F, (double)(precision[4] - 1));
+ power = HDpow(2.0, (double)(precision[4] - 1));
orig_data[i][j].b[m][n] = (char)(((long long)HDrandom() % (long long)power) << offset[4]);
} /* end for */
for (m = 0; m < (size_t)array_dims[0]; m++)
for (n = 0; n < (size_t)array_dims[1]; n++) {
- power = HDpow(2.0F, (double)(precision[0] - 1));
+ power = HDpow(2.0, (double)(precision[0] - 1));
orig_data[i][j].d[m][n].i =
(int)(-(((long long)HDrandom() % (long long)power) << offset[0]));
- power = HDpow(2.0F, (double)(precision[1] - 1));
+ power = HDpow(2.0, (double)(precision[1] - 1));
orig_data[i][j].d[m][n].c =
(char)(((long long)HDrandom() % (long long)power) << offset[1]);
- power = HDpow(2.0F, (double)(precision[2] - 1));
+ power = HDpow(2.0, (double)(precision[2] - 1));
orig_data[i][j].d[m][n].s =
(short)(((long long)HDrandom() % (long long)power) << offset[2]);
orig_data[i][j].d[m][n].f = float_val[i][j];
@@ -4292,7 +4292,7 @@ test_nbit_compound_3(hid_t file)
/* Initialize data */
for (i = 0; i < (size_t)size[0]; i++) {
- power = HDpow(2.0F, 17.0F - 1.0F);
+ power = HDpow(2.0, 17.0 - 1.0);
HDmemset(&orig_data[i], 0, sizeof(orig_data[i]));
orig_data[i].i = (int)(HDrandom() % (long)power);
HDstrcpy(orig_data[i].str, "fixed-length C string");
@@ -4481,7 +4481,7 @@ test_nbit_int_size(hid_t file)
*/
for (i = 0; i < DSET_DIM1; i++)
for (j = 0; j < DSET_DIM2; j++) {
- power = HDpow(2.0F, (double)(precision - 1));
+ power = HDpow(2.0, (double)(precision - 1));
orig[i][j] = HDrandom() % (int)power << offset;
}
@@ -5145,7 +5145,7 @@ test_scaleoffset_float(hid_t file)
/* Check that the values read are the same as the values written */
for (i = 0; i < (size_t)size[0]; i++) {
for (j = 0; j < (size_t)size[1]; j++) {
- if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0F, -3.0F)) {
+ if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0, -3.0)) {
H5_FAILED();
HDprintf(" Read different values than written.\n");
HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
@@ -5291,7 +5291,7 @@ test_scaleoffset_float_2(hid_t file)
/* Check that the values read are the same as the values written */
for (j = 0; j < (size_t)size[1]; j++) {
- if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0F, -3.0F)) {
+ if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0, -3.0)) {
H5_FAILED();
HDprintf(" Read different values than written.\n");
HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j);
@@ -5412,7 +5412,7 @@ test_scaleoffset_double(hid_t file)
/* Check that the values read are the same as the values written */
for (i = 0; i < (size_t)size[0]; i++) {
for (j = 0; j < (size_t)size[1]; j++) {
- if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0F, -7.0F)) {
+ if (HDfabs(new_data[i][j] - orig_data[i][j]) > HDpow(10.0, -7.0)) {
H5_FAILED();
HDprintf(" Read different values than written.\n");
HDprintf(" At index %lu,%lu\n", (unsigned long)i, (unsigned long)j);
@@ -5558,7 +5558,7 @@ test_scaleoffset_double_2(hid_t file)
/* Check that the values read are the same as the values written */
for (j = 0; j < (size_t)size[1]; j++) {
- if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0F, -7.0F)) {
+ if (HDfabs(new_data[0][j] - orig_data[0][j]) > HDpow(10.0, -7.0)) {
H5_FAILED();
HDprintf(" Read different values than written.\n");
HDprintf(" At index %lu,%lu\n", (unsigned long)0, (unsigned long)j);
diff --git a/test/earray.c b/test/earray.c
index 52908a7..bfd3d55 100644
--- a/test/earray.c
+++ b/test/earray.c
@@ -122,7 +122,7 @@ typedef struct earray_iter_t {
hsize_t cnt); /* Initialize/allocate iterator private info */
hssize_t (*next)(void *info); /* Get the next element to test */
hssize_t (*max_elem)(const void *info); /* Get the max. element set */
- int (*state)(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
+ int (*state)(void *in_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
earray_state_t *state, hsize_t idx); /* Get the state of the extensible array */
herr_t (*term)(void *info); /* Shutdown/free iterator private info */
} earray_iter_t;
@@ -1290,9 +1290,9 @@ eiter_fw_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_para
*-------------------------------------------------------------------------
*/
static hssize_t
-eiter_fw_next(void *_eiter)
+eiter_fw_next(void *in_eiter)
{
- eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
+ eiter_fw_t *eiter = (eiter_fw_t *)in_eiter;
hssize_t ret_val;
/* Sanity check */
@@ -1318,9 +1318,9 @@ eiter_fw_next(void *_eiter)
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
-eiter_fw_max(const void *_eiter)
+eiter_fw_max(const void *in_eiter)
{
- const eiter_fw_t *eiter = (const eiter_fw_t *)_eiter;
+ const eiter_fw_t *eiter = (const eiter_fw_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1343,10 +1343,10 @@ eiter_fw_max(const void *_eiter)
*-------------------------------------------------------------------------
*/
static int
-eiter_fw_state(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
+eiter_fw_state(void *in_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
earray_state_t *state, hsize_t idx)
{
- eiter_fw_t *eiter = (eiter_fw_t *)_eiter;
+ eiter_fw_t *eiter = (eiter_fw_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1490,9 +1490,9 @@ eiter_rv_init(const H5EA_create_t *cparam, const earray_test_param_t *tparam, hs
*-------------------------------------------------------------------------
*/
static hssize_t
-eiter_rv_next(void *_eiter)
+eiter_rv_next(void *in_eiter)
{
- eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
+ eiter_rv_t *eiter = (eiter_rv_t *)in_eiter;
hssize_t ret_val;
/* Sanity check */
@@ -1518,9 +1518,9 @@ eiter_rv_next(void *_eiter)
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
-eiter_rv_max(const void *_eiter)
+eiter_rv_max(const void *in_eiter)
{
- const eiter_rv_t *eiter = (const eiter_rv_t *)_eiter;
+ const eiter_rv_t *eiter = (const eiter_rv_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1543,10 +1543,10 @@ eiter_rv_max(const void *_eiter)
*-------------------------------------------------------------------------
*/
static int
-eiter_rv_state(void *_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
+eiter_rv_state(void *in_eiter, const H5EA_create_t *cparam, const earray_test_param_t *tparam,
earray_state_t *state, hsize_t idx)
{
- eiter_rv_t *eiter = (eiter_rv_t *)_eiter;
+ eiter_rv_t *eiter = (eiter_rv_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1720,9 +1720,9 @@ eiter_rnd_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_par
*-------------------------------------------------------------------------
*/
static hssize_t
-eiter_rnd_next(void *_eiter)
+eiter_rnd_next(void *in_eiter)
{
- eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
+ eiter_rnd_t *eiter = (eiter_rnd_t *)in_eiter;
hssize_t ret_val;
/* Sanity check */
@@ -1753,9 +1753,9 @@ eiter_rnd_next(void *_eiter)
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
-eiter_rnd_max(const void *_eiter)
+eiter_rnd_max(const void *in_eiter)
{
- const eiter_rnd_t *eiter = (const eiter_rnd_t *)_eiter;
+ const eiter_rnd_t *eiter = (const eiter_rnd_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1778,9 +1778,9 @@ eiter_rnd_max(const void *_eiter)
*-------------------------------------------------------------------------
*/
static int
-eiter_rnd_term(void *_eiter)
+eiter_rnd_term(void *in_eiter)
{
- eiter_rnd_t *eiter = (eiter_rnd_t *)_eiter;
+ eiter_rnd_t *eiter = (eiter_rnd_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1934,9 +1934,9 @@ eiter_cyc_init(const H5EA_create_t H5_ATTR_UNUSED *cparam, const earray_test_par
*-------------------------------------------------------------------------
*/
static hssize_t
-eiter_cyc_next(void *_eiter)
+eiter_cyc_next(void *in_eiter)
{
- eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
+ eiter_cyc_t *eiter = (eiter_cyc_t *)in_eiter;
hssize_t ret_val;
/* Sanity check */
@@ -1969,9 +1969,9 @@ eiter_cyc_next(void *_eiter)
*-------------------------------------------------------------------------
*/
static H5_ATTR_PURE hssize_t
-eiter_cyc_max(const void *_eiter)
+eiter_cyc_max(const void *in_eiter)
{
- const eiter_cyc_t *eiter = (const eiter_cyc_t *)_eiter;
+ const eiter_cyc_t *eiter = (const eiter_cyc_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
@@ -1994,9 +1994,9 @@ eiter_cyc_max(const void *_eiter)
*-------------------------------------------------------------------------
*/
static int
-eiter_cyc_term(void *_eiter)
+eiter_cyc_term(void *in_eiter)
{
- eiter_cyc_t *eiter = (eiter_cyc_t *)_eiter;
+ eiter_cyc_t *eiter = (eiter_cyc_t *)in_eiter;
/* Sanity check */
HDassert(eiter);
diff --git a/test/error_test.c b/test/error_test.c
index e294a43..9bbebec 100644
--- a/test/error_test.c
+++ b/test/error_test.c
@@ -129,13 +129,8 @@ test_error(hid_t file)
TEST_ERROR;
if (old_data != NULL)
TEST_ERROR;
-#ifdef H5_USE_16_API
- if (old_func != (H5E_auto_t)H5Eprint)
- TEST_ERROR;
-#else /* H5_USE_16_API */
if (old_func != (H5E_auto2_t)H5Eprint2)
TEST_ERROR;
-#endif /* H5_USE_16_API */
if (H5Eset_auto2(H5E_DEFAULT, NULL, NULL) < 0)
TEST_ERROR;
diff --git a/test/external.c b/test/external.c
index 9109e75..0957a03 100644
--- a/test/external.c
+++ b/test/external.c
@@ -465,7 +465,7 @@ error:
*-------------------------------------------------------------------------
*/
static int
-__add_external_files(hid_t dcpl_id, unsigned int n_external_files, off_t offset, hsize_t max_ext_size)
+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;
@@ -519,7 +519,7 @@ test_multiple_files(hid_t file)
max_ext_size = (hsize_t)(sizeof(int) * max_size[0] / n_external_files);
- if (__add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) {
+ if (add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) {
FAIL_STACK_ERROR;
}
@@ -543,7 +543,7 @@ test_multiple_files(hid_t file)
max_ext_size -= 1;
- if (__add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) {
+ if (add_external_files(dcpl, n_external_files, 0, max_ext_size) < 0) {
FAIL_STACK_ERROR;
}
diff --git a/test/ohdr.c b/test/ohdr.c
index 54040e1..c586ff3 100644
--- a/test/ohdr.c
+++ b/test/ohdr.c
@@ -780,7 +780,7 @@ count_attributes(hid_t dset_id)
* On success, stores size in `size_out` pointer.
*/
static herr_t
-_oh_getsize(hid_t did, hsize_t *size_out)
+oh_getsize(hid_t did, hsize_t *size_out)
{
H5O_native_info_t ninfo;
@@ -803,9 +803,9 @@ oh_compare(hid_t did1, hid_t did2)
hsize_t space1 = 0;
hsize_t space2 = 0;
- if (FAIL == _oh_getsize(did1, &space1))
+ if (FAIL == oh_getsize(did1, &space1))
return -1;
- if (FAIL == _oh_getsize(did2, &space2))
+ if (FAIL == oh_getsize(did2, &space2))
return -2;
if (space1 < space2)