summaryrefslogtreecommitdiffstats
path: root/hl/c++
diff options
context:
space:
mode:
authorDana Robinson <43805+derobins@users.noreply.github.com>2021-06-01 13:49:39 (GMT)
committerGitHub <noreply@github.com>2021-06-01 13:49:39 (GMT)
commit50d0888f491821435f6884c0c4c516f69ff67927 (patch)
treecfb3c7737ad9850667771206bc6f457da4e489fb /hl/c++
parent4ef33ef7cd0f2af55b34682b6949a101a68436bb (diff)
downloadhdf5-50d0888f491821435f6884c0c4c516f69ff67927.zip
hdf5-50d0888f491821435f6884c0c4c516f69ff67927.tar.gz
hdf5-50d0888f491821435f6884c0c4c516f69ff67927.tar.bz2
C++ warning and build fixes (#707)
* Committing clang-format changes * C++ build and warning updates * Fixes all warnings on C++ (with gcc 9.3) * Updates CMake and Autotools C++ builds * Undo warning clobber 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.cpp8
-rw-r--r--hl/c++/src/H5PacketTable.h3
-rw-r--r--hl/c++/test/ptableTest.cpp12
3 files changed, 10 insertions, 13 deletions
diff --git a/hl/c++/src/H5PacketTable.cpp b/hl/c++/src/H5PacketTable.cpp
index 0f47b0d..3fcc9b2 100644
--- a/hl/c++/src/H5PacketTable.cpp
+++ b/hl/c++/src/H5PacketTable.cpp
@@ -32,15 +32,13 @@
* Opens an existing packet table, which can contain either fixed-length or
* variable-length packets.
*/
-PacketTable::PacketTable(hid_t fileID, const char *name)
+PacketTable::PacketTable(hid_t fileID, const char *name) : table_id{H5PTopen(fileID, name)}
{
- table_id = H5PTopen(fileID, name);
}
/* "Open" Constructor - will be deprecated because of char* name */
-PacketTable::PacketTable(hid_t fileID, char *name)
+PacketTable::PacketTable(hid_t fileID, char *name) : table_id{H5PTopen(fileID, name)}
{
- table_id = H5PTopen(fileID, name);
}
/* Destructor
@@ -271,7 +269,7 @@ FL_PacketTable::GetPackets(hsize_t startIndex, hsize_t endIndex, void *data)
if (startIndex > endIndex)
return -1;
- return H5PTread_packets(table_id, startIndex, (size_t)(endIndex - startIndex + 1), data);
+ return H5PTread_packets(table_id, startIndex, static_cast<size_t>(endIndex - startIndex + 1), data);
}
/* GetNextPacket (single packet)
diff --git a/hl/c++/src/H5PacketTable.h b/hl/c++/src/H5PacketTable.h
index acd0ccf..306cc2f 100644
--- a/hl/c++/src/H5PacketTable.h
+++ b/hl/c++/src/H5PacketTable.h
@@ -33,9 +33,8 @@ class H5_HLCPPDLL PacketTable {
/* Null constructor
* Sets table_id to "invalid"
*/
- PacketTable()
+ PacketTable() : table_id{H5I_INVALID_HID}
{
- table_id = H5I_INVALID_HID;
}
/* "Open" Constructor
diff --git a/hl/c++/test/ptableTest.cpp b/hl/c++/test/ptableTest.cpp
index 2600367..6deb24d 100644
--- a/hl/c++/test/ptableTest.cpp
+++ b/hl/c++/test/ptableTest.cpp
@@ -307,7 +307,7 @@ TestCompress()
if (HDstrncmp(filter_name, "deflate", 7) != 0)
H5_FAILED()
}
- catch (Exception e) {
+ catch (Exception const &) {
H5_FAILED();
return 1;
}
@@ -605,8 +605,8 @@ const int STRING_LENGTH = 19; // including terminating NULL
int
TestHDFFV_9758()
{
- hid_t strtype;
- hid_t compound_type;
+ hid_t strtype = H5I_INVALID_HID;
+ hid_t compound_type = H5I_INVALID_HID;
herr_t err;
struct s1_t {
int a;
@@ -620,9 +620,9 @@ TestHDFFV_9758()
for (hsize_t i = 0; i < NUM_PACKETS; 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].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);
}