Skip to content

Commit

Permalink
More warning fixes (#400)
Browse files Browse the repository at this point in the history
* Fixed -Wunused-local-typedef warning

* Fixed -Wformat warnings

In one case also removed a `z` character. There was a `z%d` that I think was supposed to be `%zd`

* Fixed -Wshorten-64-to-32 warnings

* Fixed -Wself-assign warnings

* Fixed -Wreserved-id-macro warnings

* Commit format changes from clang-format, clang version 10.0.1.

* Fixed -Wself-assign warnings

* Fixed -Wunused-local-typedef warning

* Fixed -Wformat warnings

In two cases also removed a `z` character. There was a `z%d` that was supposed to be `%zd`.

* Fixed -Wshorten-64-to-32 warnings

* Fixed -Wreserved-id-macro warnings

* Fixed -Wself-assign warnings

* Format source.

* Remove blank lines to pass format check.

Co-authored-by: Larry Knox <lrknox@hdfgroup.org>
  • Loading branch information
seanm and lrknox authored Mar 4, 2021
1 parent fb210fc commit 580008d
Show file tree
Hide file tree
Showing 22 changed files with 122 additions and 103 deletions.
6 changes: 3 additions & 3 deletions c++/src/H5AbstractDs.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef AbstractDs_H
#define AbstractDs_H
#ifndef H5AbstractDs_H
#define H5AbstractDs_H

namespace H5 {

Expand Down Expand Up @@ -81,4 +81,4 @@ class H5_DLLCPP AbstractDs {
}; // end of AbstractDs
} // namespace H5

#endif // AbstractDs_H
#endif // H5AbstractDs_H
6 changes: 3 additions & 3 deletions c++/src/H5CommonFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef CommonFG_H
#define CommonFG_H
#ifndef H5CommonFG_H
#define H5CommonFG_H

namespace H5 {

Expand Down Expand Up @@ -83,7 +83,7 @@ class H5_DLLCPP CommonFG {
}; // end of CommonFG
} // namespace H5

#endif // CommonFG_H
#endif // H5CommonFG_H

/***************************************************************************
Design Note
Expand Down
6 changes: 3 additions & 3 deletions c++/src/H5Group.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef Group_H
#define Group_H
#ifndef H5Group_H
#define H5Group_H

namespace H5 {

Expand Down Expand Up @@ -83,4 +83,4 @@ class H5_DLLCPP Group : public H5Object, public CommonFG {
}; // end of Group
} // namespace H5

#endif // Group_H
#endif // H5Group_H
6 changes: 3 additions & 3 deletions c++/src/H5IdComponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef IdComponent_H
#define IdComponent_H
#ifndef H5IdComponent_H
#define H5IdComponent_H

namespace H5 {

Expand Down Expand Up @@ -113,4 +113,4 @@ class H5_DLLCPP IdComponent {
}; // end class IdComponent
} // namespace H5

#endif // IdComponent_H
#endif // H5IdComponent_H
27 changes: 15 additions & 12 deletions c++/test/tarray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ test_array_compound_array()
// Initialize array data to write
for (idxi = 0; idxi < SPACE1_DIM1; idxi++)
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
wdata[idxi][idxj].i = idxi * 10 + idxj;
wdata[idxi][idxj].i = static_cast<int>(idxi * 10 + idxj);
for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) {
float temp = idxi * 10.0 + idxj * 2.5 + idxk;
wdata[idxi][idxj].f[idxk] = temp;
Expand Down Expand Up @@ -182,8 +182,9 @@ test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n",
ii, rdims1[ii], ii, tdims1[ii]);
TestErrPrintf(
"Array dimension information doesn't match!, rdims1[%d]=%lld, tdims1[%d]=%lld\n", ii,
rdims1[ii], ii, tdims1[ii]);
continue;
} // end if

Expand All @@ -200,8 +201,9 @@ test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n",
ii, rdims1[ii], ii, tdims1[ii]);
TestErrPrintf(
"Array dimension information doesn't match!, rdims1[%d]=%lld, tdims1[%d]=%lld\n", ii,
rdims1[ii], ii, tdims1[ii]);
continue;
} // end if

Expand Down Expand Up @@ -250,8 +252,9 @@ test_array_compound_array()
// Check the array dimensions
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
TestErrPrintf("Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=%zd\n",
ii, rdims1[ii], ii, tdims1[ii]);
TestErrPrintf(
"Array dimension information doesn't match!, rdims1[%d]=%lld, tdims1[%d]=%lld\n", ii,
rdims1[ii], ii, tdims1[ii]);
continue;
} // end if

Expand All @@ -266,9 +269,9 @@ test_array_compound_array()
for (idxi = 0; idxi < SPACE1_DIM1; idxi++) {
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
if (wdata[idxi][idxj].i != rdata[idxi][idxj].i) {
TestErrPrintf(
"Array data information doesn't match!, wdata[%d][%d].i=%d, rdata[%d][%d].i=%d\n",
idxi, idxj, wdata[idxi][idxj].i, idxi, idxj, rdata[idxi][idxj].i);
TestErrPrintf("Array data information doesn't match!, wdata[%lld][%lld].i=%d, "
"rdata[%lld][%lld].i=%d\n",
idxi, idxj, wdata[idxi][idxj].i, idxi, idxj, rdata[idxi][idxj].i);
continue;
} // end if
} // end for
Expand Down Expand Up @@ -387,7 +390,7 @@ test_array_info()
// Initialize array data to write
for (idxi = 0; idxi < SPACE1_DIM1; idxi++)
for (idxj = 0; idxj < ARRAY1_DIM1; idxj++) {
wdata[idxi][idxj].i = idxi * 10 + idxj;
wdata[idxi][idxj].i = static_cast<int>(idxi * 10 + idxj);
for (idxk = 0; idxk < ARRAY1_DIM1; idxk++) {
float temp = idxi * 10.0 + idxj * 2.5 + idxk;
wdata[idxi][idxj].f[idxk] = temp;
Expand Down Expand Up @@ -459,7 +462,7 @@ test_array_info()
for (ii = 0; ii < ndims; ii++)
if (rdims1[ii] != tdims1[ii]) {
TestErrPrintf(
"Array dimension information doesn't match!, rdims1[%d]=%zd, tdims1[%d]=z%d\n", ii,
"Array dimension information doesn't match!, rdims1[%d]=%llu, tdims1[%d]=z%llu\n", ii,
rdims1[ii], ii, tdims1[ii]);
continue;
} // end if
Expand Down
54 changes: 27 additions & 27 deletions c++/test/tattr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ test_attr_basic_write()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
i, attr_data1[i], i, read_data1[i]);
TestErrPrintf("%d: attribute data different: attr_data1[%llu]=%d,read_data1[%llu]=%d\n",
__LINE__, i, attr_data1[i], i, read_data1[i]);

// Create two more attributes for this dataset, but only write to one.
Attribute ds_attr2 = dataset.createAttribute(ATTR2_NAME, PredType::NATIVE_INT, att_space);
Expand All @@ -189,7 +189,7 @@ test_attr_basic_write()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1a[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",
TestErrPrintf("%d: attribute data different: attr_data1a[%llu]=%d,read_data1[%llu]=%d\n",
__LINE__, i, attr_data1a[i], i, read_data1[i]);

// Close both attributes
Expand Down Expand Up @@ -452,8 +452,8 @@ test_attr_rename()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
i, attr_data1[i], i, read_data1[i]);
TestErrPrintf("%d: attribute data different: attr_data1[%llu]=%d,read_data1[%llu%d\n",
__LINE__, i, attr_data1[i], i, read_data1[i]);

// Close attribute
attr1.close();
Expand All @@ -476,7 +476,7 @@ test_attr_rename()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1a[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1a[%d]=%d,read_data1[%d]=%d\n",
TestErrPrintf("%d: attribute data different: attr_data1a[%llu]=%d,read_data1[%llu]=%d\n",
__LINE__, i, attr_data1a[i], i, read_data1[i]);

// Close attribute
Expand Down Expand Up @@ -541,7 +541,7 @@ test_attr_basic_read()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d, read_data1[%d]=%d\n",
TestErrPrintf("%d: attribute data different: attr_data1[%llu]=%d, read_data1[%llu]=%d\n",
__LINE__, i, attr_data1[i], i, read_data1[i]);

/*
Expand Down Expand Up @@ -572,9 +572,9 @@ test_attr_basic_read()
for (i = 0; i < ATTR2_DIM1; i++)
for (j = 0; j < ATTR2_DIM2; j++)
if (attr_data2[i][j] != read_data2[i][j]) {
TestErrPrintf(
"%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
__LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
TestErrPrintf("%d: attribute data different: attr_data2[%llu][%llu]=%d, "
"read_data2[%llu][%llu]=%d\n",
__LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
}
PASSED();
} // end try block
Expand Down Expand Up @@ -776,15 +776,15 @@ test_attr_compound_read()
for (ii = 0; ii < ATTR4_DIM1; ii++)
for (jj = 0; jj < ATTR4_DIM2; jj++)
if (HDmemcmp(&attr_data4[ii][jj], &read_data4[ii][jj], sizeof(struct attr4_struct))) {
TestErrPrintf(
"%d:attribute data different: attr_data4[%d][%d].i=%d, read_data4[%d][%d].i=%d\n",
__LINE__, ii, jj, attr_data4[ii][jj].i, ii, jj, read_data4[ii][jj].i);
TestErrPrintf(
"%d:attribute data different: attr_data4[%d][%d].d=%f, read_data4[%d][%d].d=%f\n",
__LINE__, ii, jj, attr_data4[ii][jj].d, ii, jj, read_data4[ii][jj].d);
TestErrPrintf(
"%d:attribute data different: attr_data4[%d][%d].c=%c, read_data4[%d][%d].c=%c\n",
__LINE__, ii, jj, attr_data4[ii][jj].c, ii, jj, read_data4[ii][jj].c);
TestErrPrintf("%d:attribute data different: attr_data4[%llu][%llu].i=%d, "
"read_data4[%llu][%llu].i=%d\n",
__LINE__, ii, jj, attr_data4[ii][jj].i, ii, jj, read_data4[ii][jj].i);
TestErrPrintf("%d:attribute data different: attr_data4[%llu][%llu].d=%f, "
"read_data4[%llu][%llu].d=%f\n",
__LINE__, ii, jj, attr_data4[ii][jj].d, ii, jj, read_data4[ii][jj].d);
TestErrPrintf("%d:attribute data different: attr_data4[%llu][%llu].c=%c, "
"read_data4[%llu][%llu].c=%c\n",
__LINE__, ii, jj, attr_data4[ii][jj].c, ii, jj, read_data4[ii][jj].c);
} /* end if */

// Verify name
Expand Down Expand Up @@ -1048,7 +1048,7 @@ test_attr_mult_read()
hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
int ndims = space.getSimpleExtentDims(dims);
if ((long)dims[0] != (long)ATTR1_DIM1)
TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %d\n", __LINE__,
TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %llu\n", __LINE__,
(int)dims[0], ATTR1_DIM1);

/* Verify Datatype */
Expand Down Expand Up @@ -1076,8 +1076,8 @@ test_attr_mult_read()
// Verify values read in
for (i = 0; i < ATTR1_DIM1; i++)
if (attr_data1[i] != read_data1[i])
TestErrPrintf("%d: attribute data different: attr_data1[%d]=%d,read_data1[%d]=%d\n", __LINE__,
i, attr_data1[i], i, read_data1[i]);
TestErrPrintf("%d: attribute data different: attr_data1[%llu]=%d,read_data1[%llu]=%d\n",
__LINE__, i, attr_data1[i], i, read_data1[i]);

// Verify Name
H5std_string attr_name = attr.getName();
Expand Down Expand Up @@ -1131,9 +1131,9 @@ test_attr_mult_read()
for (i = 0; i < ATTR2_DIM1; i++)
for (j = 0; j < ATTR2_DIM2; j++)
if (attr_data2[i][j] != read_data2[i][j])
TestErrPrintf(
"%d: attribute data different: attr_data2[%d][%d]=%d, read_data2[%d][%d]=%d\n",
__LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);
TestErrPrintf("%d: attribute data different: attr_data2[%llu][%llu]=%d, "
"read_data2[%llu][%llu]=%d\n",
__LINE__, i, j, attr_data2[i][j], i, j, read_data2[i][j]);

// Verify Name
attr_name = attr.getName();
Expand Down Expand Up @@ -1186,8 +1186,8 @@ test_attr_mult_read()
for (j = 0; j < ATTR3_DIM2; j++)
for (k = 0; k < ATTR3_DIM3; k++)
if (attr_data3[i][j][k] != read_data3[i][j][k])
TestErrPrintf("%d: attribute data different: attr_data3[%d][%d][%d]=%f, "
"read_data3[%d][%d][%d]=%f\n",
TestErrPrintf("%d: attribute data different: attr_data3[%llu][%llu][%llu]=%f, "
"read_data3[%llu][%llu][%llu]=%f\n",
__LINE__, i, j, k, attr_data3[i][j][k], i, j, k, read_data3[i][j][k]);

// Verify Name
Expand Down
2 changes: 1 addition & 1 deletion examples/h5_attribute.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ attr_info(hid_t loc_id, const char *name, const H5A_info_t *ainfo, void *opdata)
float * float_array; /* Pointer to the array attribute. */

/* avoid warnings */
opdata = opdata;
(void)opdata;

/*
* Open the attribute using its name.
Expand Down
10 changes: 5 additions & 5 deletions examples/h5_group.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ static herr_t
file_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdata)
{
/* avoid compiler warnings */
loc_id = loc_id;
opdata = opdata;
linfo = linfo;
(void)loc_id;
(void)opdata;
(void)linfo;

/*
* Display group name. The name is passed to the function by
Expand All @@ -198,8 +198,8 @@ group_info(hid_t loc_id, const char *name, const H5L_info2_t *linfo, void *opdat
int rank_chunk;

/* avoid warnings */
opdata = opdata;
linfo = linfo;
(void)opdata;
(void)linfo;

/*
* Open the datasets using their names.
Expand Down
4 changes: 2 additions & 2 deletions hl/c++/test/ptableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -616,11 +616,11 @@ TestHDFFV_9758()
s1_t s1[NUM_PACKETS];

for (hsize_t i = 0; i < NUM_PACKETS; i++) {
s1[i].a = i;
s1[i].a = static_cast<int>(i);
s1[i].b = 1.f * static_cast<float>(i * i);
s1[i].c = 1. / (i + 1);
HDsprintf(s1[i].d, "string%d", (int)i);
s1[i].e = 100 + i;
s1[i].e = static_cast<int>(100 + i);
}

printf("Testing %-62s", "data corruption in packed structs (HDFFV-9758)");
Expand Down
5 changes: 5 additions & 0 deletions hl/src/H5IM.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ find_palette(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const
if (name == NULL)
return -1;

/* Shut compiler up */
(void)loc_id;
(void)ainfo;
(void)op_data;

/* Define a positive value for return value if the attribute was found. This will
* cause the iterator to immediately return that positive value,
* indicating short-circuit success
Expand Down
8 changes: 8 additions & 0 deletions hl/src/H5LT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,10 @@ find_dataset(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const
if (name == NULL)
return ret;

/* Shut the compiler up */
(void)loc_id;
(void)linfo;

/* Define a positive value for return value if the dataset was found. This will
* cause the iterator to immediately return that positive value,
* indicating short-circuit success
Expand Down Expand Up @@ -1847,6 +1851,10 @@ find_attr(H5_ATTR_UNUSED hid_t loc_id, const char *name, H5_ATTR_UNUSED const H5
if (name == NULL)
return H5_ITER_CONT;

/* Shut compiler up */
(void)loc_id;
(void)ainfo;

/* Define a positive value for return value if the attribute was found. This will
* cause the iterator to immediately return that positive value,
* indicating short-circuit success
Expand Down
Loading

0 comments on commit 580008d

Please sign in to comment.