summaryrefslogtreecommitdiffstats
path: root/c++
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 /c++
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 'c++')
-rw-r--r--c++/src/H5Attribute.cpp2
-rw-r--r--c++/src/H5DcreatProp.cpp4
-rw-r--r--c++/src/H5DcreatProp.h2
-rw-r--r--c++/src/H5DxferProp.cpp2
-rw-r--r--c++/src/H5Exception.cpp2
-rw-r--r--c++/src/H5File.cpp2
-rw-r--r--c++/src/H5Location.cpp11
-rw-r--r--c++/src/H5Object.cpp2
-rw-r--r--c++/test/dsets.cpp2
-rw-r--r--c++/test/h5cpputil.cpp4
-rw-r--r--c++/test/h5cpputil.h4
11 files changed, 18 insertions, 19 deletions
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index d893fec..b74349c 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -308,7 +308,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);
diff --git a/c++/src/H5DcreatProp.cpp b/c++/src/H5DcreatProp.cpp
index d670b74..0ffcbf7 100644
--- a/c++/src/H5DcreatProp.cpp
+++ b/c++/src/H5DcreatProp.cpp
@@ -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);
}
diff --git a/c++/src/H5DcreatProp.h b/c++/src/H5DcreatProp.h
index 3c032ee..820c0d1 100644
--- a/c++/src/H5DcreatProp.h
+++ b/c++/src/H5DcreatProp.h
@@ -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.
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp
index d9d7884..98e6214 100644
--- a/c++/src/H5DxferProp.cpp
+++ b/c++/src/H5DxferProp.cpp
@@ -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);
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index 1aa8ecc..8ea20ff 100644
--- a/c++/src/H5Exception.cpp
+++ b/c++/src/H5Exception.cpp
@@ -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
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index bbdcd6b..e40cafe 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -178,7 +178,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
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 2d14bfc..b136faa 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -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);
@@ -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
//--------------------------------------------------------------------------
@@ -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 */
//--------------------------------------------------------------------------
@@ -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
@@ -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
@@ -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
@@ -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 */
//--------------------------------------------------------------------------
@@ -2433,6 +2434,4 @@ f_DataSpace_setId(DataSpace *dspace, hid_t new_id)
//--------------------------------------------------------------------------
H5Location::~H5Location() {}
-#endif // DOXYGEN_SHOULD_SKIP_THIS
-
} // namespace H5
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index 725d1da..c2eba8d 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -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));
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index 93c266f..0faf457 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -1157,7 +1157,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");
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index d42fc8c..38f9300 100644
--- a/c++/test/h5cpputil.cpp
+++ b/c++/test/h5cpputil.cpp
@@ -212,7 +212,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)
{
}
@@ -237,7 +237,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)
{
}
diff --git a/c++/test/h5cpputil.h b/c++/test/h5cpputil.h
index 4439ae3..444bc68 100644
--- a/c++/test/h5cpputil.h
+++ b/c++/test/h5cpputil.h
@@ -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();
};