Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various clang tidy warning fixes #448

Merged
merged 8 commits into from
Mar 10, 2021
2 changes: 1 addition & 1 deletion c++/src/H5Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Attribute::getName(char *attr_name, size_t buf_size) const
H5std_string
Attribute::getName() const
{
H5std_string attr_name(""); // attribute name to return
H5std_string attr_name; // attribute name to return

// Preliminary call to get the size of the attribute name
ssize_t name_size = H5Aget_name(id, static_cast<size_t>(0), NULL);
Expand Down
4 changes: 2 additions & 2 deletions c++/src/H5DcreatProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ DSetCreatPropList::setVirtual(const DataSpace &vspace, const char *src_fname, co
// Programmer Binh-Minh Ribler - Mar, 2017
//--------------------------------------------------------------------------
void
DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string src_fname,
const H5std_string src_dsname, const DataSpace &sspace) const
DSetCreatPropList::setVirtual(const DataSpace &vspace, const H5std_string &src_fname,
const H5std_string &src_dsname, const DataSpace &sspace) const
{
setVirtual(vspace, src_fname.c_str(), src_dsname.c_str(), sspace);
}
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5DcreatProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class H5_DLLCPP DSetCreatPropList : public ObjCreatPropList {
// Maps elements of a virtual dataset to elements of the source dataset.
void setVirtual(const DataSpace &vspace, const char *src_fname, const char *src_dsname,
const DataSpace &sspace) const;
void setVirtual(const DataSpace &vspace, const H5std_string src_fname, const H5std_string src_dsname,
void setVirtual(const DataSpace &vspace, const H5std_string &src_fname, const H5std_string &src_dsname,
const DataSpace &sspace) const;

///\brief Returns this class name.
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5DxferProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ DSetMemXferPropList::getDataTransform() const
{
// Initialize string to "", so that if there is no expression, the returned
// string will be empty
H5std_string expression("");
H5std_string expression;

// Preliminary call to get the expression's length
ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0);
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5Exception.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const char Exception::DEFAULT_MSG[] = "No detailed information provided";
///\brief Default constructor.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
Exception::Exception() : detail_message(""), func_name("") {}
Exception::Exception() {}

//--------------------------------------------------------------------------
// Function: Exception overloaded constructor
Expand Down
2 changes: 1 addition & 1 deletion c++/src/H5File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ H5File::H5File(hid_t existing_id) : Group()
///\param original - IN: H5File instance to copy
// December 2000
//--------------------------------------------------------------------------
H5File::H5File(const H5File &original) : Group()
H5File::H5File(const H5File &original) : Group(original)
{
id = original.getId();
incRefCount(); // increment number of references to this id
Expand Down
11 changes: 5 additions & 6 deletions c++/src/H5Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ H5Location::getComment(const char *name, size_t buf_size) const
{
// Initialize string to "", so that if there is no comment, the returned
// string will be empty
H5std_string comment("");
H5std_string comment;

// Preliminary call to get the comment's length
ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, (size_t)0, H5P_DEFAULT);
Expand Down Expand Up @@ -398,6 +398,7 @@ H5Location::getComment(const H5std_string &name, size_t buf_size) const
{
return (getComment(name.c_str(), buf_size));
}

#ifndef DOXYGEN_SHOULD_SKIP_THIS

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -646,6 +647,7 @@ H5Location::p_get_obj_type(void *ref, H5R_type_t ref_type) const
return (obj_type);
}
#endif // DOXYGEN_SHOULD_SKIP_THIS

#endif /* H5_NO_DEPRECATED_SYMBOLS */

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -704,6 +706,7 @@ H5Location::p_get_ref_obj_type(void *ref, H5R_type_t ref_type) const
}
return (obj_type);
}
#endif // DOXYGEN_SHOULD_SKIP_THIS

//--------------------------------------------------------------------------
// Function: H5Location::getRegion
Expand Down Expand Up @@ -1816,7 +1819,7 @@ H5Location::getLinkval(const char *name, size_t size) const
H5L_info2_t linkinfo;
char * value_C; // value in C string
size_t val_size = size;
H5std_string value = "";
H5std_string value;
herr_t ret_value;

// if user doesn't provide buffer size, determine it
Expand Down Expand Up @@ -2294,7 +2297,6 @@ H5Location::childObjVersion(const H5std_string &objname) const
}

#ifndef H5_NO_DEPRECATED_SYMBOLS
#ifndef DOXYGEN_SHOULD_SKIP_THIS
//--------------------------------------------------------------------------
// Function: H5Location::getObjTypeByIdx
///\brief Returns the type of an object in this group, given the
Expand Down Expand Up @@ -2372,7 +2374,6 @@ H5Location::getObjTypeByIdx(hsize_t idx, H5std_string &type_name) const
return (obj_type);
}

#endif // DOXYGEN_SHOULD_SKIP_THIS
#endif /* H5_NO_DEPRECATED_SYMBOLS */

//--------------------------------------------------------------------------
Expand Down Expand Up @@ -2433,6 +2434,4 @@ f_DataSpace_setId(DataSpace *dspace, hid_t new_id)
//--------------------------------------------------------------------------
H5Location::~H5Location() {}

#endif // DOXYGEN_SHOULD_SKIP_THIS

} // namespace H5
2 changes: 1 addition & 1 deletion c++/src/H5Object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ H5Object::getObjName(char *obj_name, size_t buf_size) const
H5std_string
H5Object::getObjName() const
{
H5std_string obj_name(""); // object name to return
H5std_string obj_name; // object name to return

// Preliminary call to get the size of the object name
ssize_t name_size = H5Iget_name(getId(), NULL, static_cast<size_t>(0));
Expand Down
2 changes: 1 addition & 1 deletion c++/test/dsets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ const int RANK1 = 1;
const H5std_string FILE_ACCPLIST("test_accplist.h5");

static herr_t
test_chunk_cache(FileAccPropList fapl)
test_chunk_cache(const FileAccPropList &fapl)
{
SUBTEST("DSetAccPropList::set/getChunkCache");

Expand Down
4 changes: 2 additions & 2 deletions c++/test/h5cpputil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ InvalidActionException::InvalidActionException() : Exception() {}
// func - IN: Name of the function where failure should occur
// message - IN: Message
//--------------------------------------------------------------------------
InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message)
InvalidActionException::InvalidActionException(const H5std_string &func, const H5std_string &message)
: Exception(func, message)
{
}
Expand All @@ -241,7 +241,7 @@ TestFailedException::TestFailedException() : Exception() {}
// func - IN: Name of the function where failure should occur
// message - IN: Message
//--------------------------------------------------------------------------
TestFailedException::TestFailedException(const H5std_string func, const H5std_string message)
TestFailedException::TestFailedException(const H5std_string &func, const H5std_string &message)
: Exception(func, message)
{
}
Expand Down
4 changes: 2 additions & 2 deletions c++/test/h5cpputil.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ void issue_fail_msg(const char *where, int line, const char *file_name, const ch

class InvalidActionException : public Exception {
public:
InvalidActionException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
InvalidActionException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
InvalidActionException();
virtual ~InvalidActionException() throw();
};

class TestFailedException : public Exception {
public:
TestFailedException(const H5std_string func_name, const H5std_string message = DEFAULT_MSG);
TestFailedException(const H5std_string &func_name, const H5std_string &message = DEFAULT_MSG);
TestFailedException();
virtual ~TestFailedException() throw();
};
Expand Down
4 changes: 2 additions & 2 deletions src/H5Tconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -8477,7 +8477,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
/* Allocate enough space for the buffer holding temporary
* converted value
*/
buf_size = (size_t)(HDpow((double)2.0f, (double)src.u.f.esize) / 8 + 1);
buf_size = (size_t)(HDpow(2.0, (double)src.u.f.esize) / 8 + 1);
int_buf = (uint8_t *)H5MM_calloc(buf_size);

/* Get conversion exception callback property */
Expand Down Expand Up @@ -9315,7 +9315,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz
}

/* Check if the exponent is too big */
expo_max = (hsize_t)(HDpow((double)2.0f, (double)dst.u.f.esize) - 1);
expo_max = (hsize_t)(HDpow(2.0, (double)dst.u.f.esize) - 1);

if (expo > expo_max) { /*overflows*/
if (cb_struct.func) { /*user's exception handler. Reverse back source order*/
Expand Down
4 changes: 2 additions & 2 deletions src/H5Zscaleoffset.c
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,12 @@ H5Z_class2_t H5Z_SCALEOFFSET[1] = {{
#define H5Z_scaleoffset_max_min_3(i, d_nelmts, buf, filval, max, min, D_val) \
{ \
i = 0; \
while (i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \
while (i < d_nelmts && HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \
i++; \
if (i < d_nelmts) \
min = max = buf[i]; \
for (; i < d_nelmts; i++) { \
if (HDfabs(buf[i] - filval) < HDpow(10.0f, -D_val)) \
if (HDfabs(buf[i] - filval) < HDpow(10.0, -D_val)) \
continue; /* ignore fill value */ \
if (buf[i] > max) \
max = buf[i]; \
Expand Down
4 changes: 2 additions & 2 deletions test/cache_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions test/dsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading