summaryrefslogtreecommitdiffstats
path: root/hl/c++
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-08-23 21:14:53 (GMT)
committerGitHub <noreply@github.com>2021-08-23 21:14:53 (GMT)
commitf6c49fe8911a39810b236f7babf09a70fcc76c7b (patch)
tree4ee702ab548adf8e619525e14716dde7d26bb331 /hl/c++
parentb5f5c59f297be19096051282068cdcc14275eb34 (diff)
downloadhdf5-f6c49fe8911a39810b236f7babf09a70fcc76c7b.zip
hdf5-f6c49fe8911a39810b236f7babf09a70fcc76c7b.tar.gz
hdf5-f6c49fe8911a39810b236f7babf09a70fcc76c7b.tar.bz2
More clang tidy (#908)
* Pacify clang-analyzer-unix.cstring.NullArg * Apply some bugprone-suspicious-string-compare * Apply some readability-simplify-boolean-expr * Apply some readability-make-member-function-const * Apple some bugprone-macro-parentheses * Changed an f suffix to L for `long double` * Applied some readability-uppercase-literal-suffix automatically * Committing clang-format changes Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'hl/c++')
-rw-r--r--hl/c++/src/H5PacketTable.cpp25
-rw-r--r--hl/c++/src/H5PacketTable.h20
-rw-r--r--hl/c++/test/ptableTest.cpp2
3 files changed, 22 insertions, 25 deletions
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp
index 2908626..086c702 100644
--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -62,12 +62,9 @@ PacketTable::~PacketTable()
* any trouble making or opening the packet table.
*/
bool
-PacketTable::IsValid()
+PacketTable::IsValid() const
{
- if (H5PTis_valid(table_id) == 0)
- return true;
- else
- return false;
+ return H5PTis_valid(table_id) == 0;
}
/* IsVariableLength
@@ -75,7 +72,7 @@ PacketTable::IsValid()
* and 0, otherwise. Returns -1 if the table is invalid (not open).
*/
int
-PacketTable::IsVariableLength()
+PacketTable::IsVariableLength() const
{
return H5PTis_varlen(table_id);
}
@@ -84,7 +81,7 @@ PacketTable::IsVariableLength()
* Sets the index to point to the first packet in the packet table
*/
void
-PacketTable::ResetIndex()
+PacketTable::ResetIndex() const
{
H5PTcreate_index(table_id);
}
@@ -94,7 +91,7 @@ PacketTable::ResetIndex()
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
int
-PacketTable::SetIndex(hsize_t index)
+PacketTable::SetIndex(hsize_t index) const
{
return H5PTset_index(table_id, index);
}
@@ -104,7 +101,7 @@ PacketTable::SetIndex(hsize_t index)
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
hsize_t
-PacketTable::GetIndex(int &error)
+PacketTable::GetIndex(int &error) const
{
hsize_t index;
@@ -121,7 +118,7 @@ PacketTable::GetIndex(int &error)
* error is set to negative.
*/
hsize_t
-PacketTable::GetPacketCount(int &error)
+PacketTable::GetPacketCount(int &error) const
{
hsize_t npackets;
@@ -133,7 +130,7 @@ PacketTable::GetPacketCount(int &error)
* Returns the identifier of the packet table
*/
hid_t
-PacketTable::GetTableId()
+PacketTable::GetTableId() const
{
return table_id;
}
@@ -145,7 +142,7 @@ PacketTable::GetTableId()
* the desired functionality cannot be performed via the packet table ID.
*/
hid_t
-PacketTable::GetDatatype()
+PacketTable::GetDatatype() const
{
return H5PTget_type(table_id);
}
@@ -157,7 +154,7 @@ PacketTable::GetDatatype()
* the desired functionality cannot be performed via the packet table ID.
*/
hid_t
-PacketTable::GetDataset()
+PacketTable::GetDataset() const
{
return H5PTget_dataset(table_id);
}
@@ -169,7 +166,7 @@ PacketTable::GetDataset()
* Returns 0 on success, negative on error.
*/
int
-PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer)
+PacketTable::FreeBuff(size_t numStructs, hvl_t *buffer) const
{
return H5PTfree_vlen_buff(table_id, numStructs, buffer);
}
diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h
index eae66f1..c1f1eb5 100644
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -54,39 +54,39 @@ class H5_HLCPPDLL PacketTable {
* Use this after the constructor to ensure HDF did not have
* any trouble making or opening the packet table.
*/
- bool IsValid();
+ bool IsValid() const;
/* IsVariableLength
* Return 1 if this packet table uses variable-length datatype,
* return 0 if it is Fixed Length. Returns -1 if the table is
* invalid (not open).
*/
- int IsVariableLength();
+ int IsVariableLength() const;
/* ResetIndex
* Sets the "current packet" index to point to the first packet in the
* packet table
*/
- void ResetIndex();
+ void ResetIndex() const;
/* SetIndex
* Sets the current packet to point to the packet specified by index.
* Returns 0 on success, negative on failure (if index is out of bounds)
*/
- int SetIndex(hsize_t index);
+ int SetIndex(hsize_t index) const;
/* GetIndex
* Returns the position of the current packet.
* On failure, returns 0 and error is set to negative.
*/
- hsize_t GetIndex(int &error);
+ hsize_t GetIndex(int &error) const;
/* GetPacketCount
* Returns the number of packets in the packet table. Error
* is set to 0 on success. On failure, returns 0 and
* error is set to negative.
*/
- hsize_t GetPacketCount(int &error);
+ hsize_t GetPacketCount(int &error) const;
hsize_t
GetPacketCount()
@@ -98,7 +98,7 @@ class H5_HLCPPDLL PacketTable {
/* GetTableId
* Returns the identifier of the packet table.
*/
- hid_t GetTableId();
+ hid_t GetTableId() const;
/* GetDatatype
* Returns the datatype identifier used by the packet table, on success,
@@ -106,7 +106,7 @@ class H5_HLCPPDLL PacketTable {
* Note: it is best to avoid using this identifier in applications, unless
* the desired functionality cannot be performed via the packet table ID.
*/
- hid_t GetDatatype();
+ hid_t GetDatatype() const;
/* GetDataset
* Returns the dataset identifier associated with the packet table, on
@@ -114,7 +114,7 @@ class H5_HLCPPDLL PacketTable {
* Note: it is best to avoid using this identifier in applications, unless
* the desired functionality cannot be performed via the packet table ID.
*/
- hid_t GetDataset();
+ hid_t GetDataset() const;
/* FreeBuff
* Frees the buffers created when variable-length packets are read.
@@ -122,7 +122,7 @@ class H5_HLCPPDLL PacketTable {
* location in memory.
* Returns 0 on success, negative on error.
*/
- int FreeBuff(size_t numStructs, hvl_t *buffer);
+ int FreeBuff(size_t numStructs, hvl_t *buffer) const;
protected:
hid_t table_id;
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index 6deb24d..ab49303 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -620,7 +620,7 @@ TestHDFFV_9758()
for (hsize_t i = 0; i < NUM_PACKETS; i++) {
s1[i].a = static_cast<int>(i);
- s1[i].b = 1.0f * static_cast<float>(i * i);
+ s1[i].b = 1.0F * static_cast<float>(i * i);
s1[i].c = 1.0 / static_cast<double>(i + 1);
HDsprintf(s1[i].d, "string%" PRIuHSIZE "", i);
s1[i].e = static_cast<int>(100 + i);