summaryrefslogtreecommitdiffstats
path: root/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 /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 'c++')
-rw-r--r--c++/src/CMakeLists.txt7
-rw-r--r--c++/src/H5Cpp.h10
-rw-r--r--c++/src/H5DataSpace.cpp7
-rw-r--r--c++/src/H5DataType.cpp24
-rw-r--r--c++/src/H5DxferProp.cpp4
-rw-r--r--c++/src/H5Exception.cpp2
-rw-r--r--c++/src/H5File.cpp6
-rw-r--r--c++/src/H5LcreatProp.cpp4
-rw-r--r--c++/src/H5Location.cpp2
-rw-r--r--c++/src/H5PropList.cpp8
-rw-r--r--c++/test/dsets.cpp49
-rw-r--r--c++/test/tarray.cpp12
-rw-r--r--c++/test/tattr.cpp148
-rw-r--r--c++/test/tcompound.cpp78
-rw-r--r--c++/test/tdspl.cpp18
-rw-r--r--c++/test/tfile.cpp51
-rw-r--r--c++/test/th5s.cpp20
-rw-r--r--c++/test/titerate.cpp29
-rw-r--r--c++/test/tlinks.cpp12
-rw-r--r--c++/test/tobject.cpp38
-rw-r--r--c++/test/trefer.cpp162
-rw-r--r--c++/test/ttypes.cpp9
-rw-r--r--c++/test/tvlstr.cpp54
23 files changed, 412 insertions, 342 deletions
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 835d422..2a37dea 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -2,13 +2,6 @@ cmake_minimum_required (VERSION 3.12)
project (HDF5_CPP_SRC CXX)
#-----------------------------------------------------------------------------
-# Generate configure file
-#-----------------------------------------------------------------------------
-configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in
- ${HDF5_SRC_BINARY_DIR}/H5cxx_pubconf.h
-)
-
-#-----------------------------------------------------------------------------
# Define cpp Library
#-----------------------------------------------------------------------------
set (CPP_SOURCES
diff --git a/c++/src/H5Cpp.h b/c++/src/H5Cpp.h
index 9272bdb..202d584 100644
--- a/c++/src/H5Cpp.h
+++ b/c++/src/H5Cpp.h
@@ -48,14 +48,4 @@
#include "H5File.h"
#include "H5Library.h"
-/* Some C++ compilers do not have offsetof macro; define to bypass the problem
- - BMR- -EIP- 2007/08/01
-*/
-#ifndef H5_CXX_HAVE_OFFSETOF
-#ifdef HOFFSET
-#undef HOFFSET
-#endif
-#define HOFFSET(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER)
-#endif
-
#endif // H5Cpp_H
diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp
index c20a88c..342e9fa 100644
--- a/c++/src/H5DataSpace.cpp
+++ b/c++/src/H5DataSpace.cpp
@@ -88,9 +88,8 @@ const DataSpace &DataSpace::ALL = *getConstant();
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(H5S_class_t type) : IdComponent()
+DataSpace::DataSpace(H5S_class_t type) : IdComponent(), id{H5Screate(type)}
{
- id = H5Screate(type);
if (id < 0) {
throw DataSpaceIException("DataSpace constructor", "H5Screate failed");
}
@@ -105,9 +104,9 @@ DataSpace::DataSpace(H5S_class_t type) : IdComponent()
///\exception H5::DataSpaceIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims) : IdComponent()
+DataSpace::DataSpace(int rank, const hsize_t *dims, const hsize_t *maxdims)
+ : IdComponent(), id{H5Screate_simple(rank, dims, maxdims)}
{
- id = H5Screate_simple(rank, dims, maxdims);
if (id < 0) {
throw DataSpaceIException("DataSpace constructor", "H5Screate_simple failed");
}
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 3228dcb..cdf28cf 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -76,10 +76,9 @@ DataType::DataType(const hid_t existing_id) : H5Object(), id(existing_id), encod
///\exception H5::DataTypeIException
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), encoded_buf(NULL), buf_size(0)
+DataType::DataType(const H5T_class_t type_class, size_t size)
+ : H5Object(), id{H5Tcreate(type_class, size)}, encoded_buf(NULL), buf_size(0)
{
- // Call C routine to create the new datatype
- id = H5Tcreate(type_class, size);
if (id < 0) {
throw DataTypeIException("DataType constructor", "H5Tcreate failed");
}
@@ -97,9 +96,10 @@ DataType::DataType(const H5T_class_t type_class, size_t size) : H5Object(), enco
// Programmer Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
DataType::DataType(const H5Location &loc, const void *ref, H5R_type_t ref_type, const PropList &plist)
- : H5Object(), encoded_buf(NULL), buf_size(0)
+ : H5Object(), id{H5Location::p_dereference(loc.getId(), ref, ref_type, plist,
+ "constructor - by dereference")},
+ encoded_buf(NULL), buf_size(0)
{
- id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference");
}
//--------------------------------------------------------------------------
@@ -146,10 +146,9 @@ DataType::DataType(const DataType &original) : H5Object(), id(original.id), enco
// unnecessarily and will produce undefined behavior.
// -BMR, Apr 2015
//--------------------------------------------------------------------------
-DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), buf_size(0)
+DataType::DataType(const PredType &pred_type)
+ : H5Object(), id{H5Tcopy(pred_type.getId())}, encoded_buf(NULL), buf_size(0)
{
- // Call C routine to copy the datatype
- id = H5Tcopy(pred_type.getId());
if (id < 0)
throw DataTypeIException("DataType constructor", "H5Tcopy failed");
}
@@ -168,9 +167,9 @@ DataType::DataType(const PredType &pred_type) : H5Object(), encoded_buf(NULL), b
// improve usability.
// -BMR, Dec 2016
//--------------------------------------------------------------------------
-DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(), encoded_buf(NULL), buf_size(0)
+DataType::DataType(const H5Location &loc, const char *dtype_name)
+ : H5Object(), id{p_opentype(loc, dtype_name)}, encoded_buf(NULL), buf_size(0)
{
- id = p_opentype(loc, dtype_name);
}
//--------------------------------------------------------------------------
@@ -188,9 +187,8 @@ DataType::DataType(const H5Location &loc, const char *dtype_name) : H5Object(),
// -BMR, Dec 2016
//--------------------------------------------------------------------------
DataType::DataType(const H5Location &loc, const H5std_string &dtype_name)
- : H5Object(), encoded_buf(NULL), buf_size(0)
+ : H5Object(), id{p_opentype(loc, dtype_name.c_str())}, encoded_buf(NULL), buf_size(0)
{
- id = p_opentype(loc, dtype_name.c_str());
}
//--------------------------------------------------------------------------
@@ -318,7 +316,7 @@ DataType::encode()
// Allocate buffer and call C function again to encode
if (buf_size > 0) {
- encoded_buf = (unsigned char *)HDcalloc((size_t)1, buf_size);
+ encoded_buf = static_cast<unsigned char *>(HDcalloc(1, buf_size));
ret_value = H5Tencode(id, encoded_buf, &buf_size);
if (ret_value < 0) {
throw DataTypeIException("DataType::encode", "H5Tencode failed");
diff --git a/c++/src/H5DxferProp.cpp b/c++/src/H5DxferProp.cpp
index 43ea6f4..40faac2 100644
--- a/c++/src/H5DxferProp.cpp
+++ b/c++/src/H5DxferProp.cpp
@@ -175,7 +175,7 @@ DSetMemXferPropList::getBuffer(void **tconv, void **bkg) const
void
DSetMemXferPropList::setPreserve(bool status) const
{
- herr_t ret_value = H5Pset_preserve(id, (hbool_t)status);
+ herr_t ret_value = H5Pset_preserve(id, static_cast<hbool_t>(status));
if (ret_value < 0) {
throw PropListIException("DSetMemXferPropList::setPreserve", "H5Pset_preserve failed");
}
@@ -314,7 +314,7 @@ DSetMemXferPropList::getDataTransform() const
H5std_string expression;
// Preliminary call to get the expression's length
- ssize_t exp_len = H5Pget_data_transform(id, NULL, (size_t)0);
+ ssize_t exp_len = H5Pget_data_transform(id, NULL, 0);
// If H5Pget_data_transform returns a negative value, raise an exception
if (exp_len < 0) {
diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp
index 6769439..a42c151 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()
+Exception::Exception() : detail_message{""}, func_name{""}
{
}
diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp
index 9a6f191..f92171b 100644
--- a/c++/src/H5File.cpp
+++ b/c++/src/H5File.cpp
@@ -165,9 +165,8 @@ H5File::p_get_file(const char *name, unsigned int flags, const FileCreatPropList
// constructor is needed by the library in order to return
// an object, H5File doesn't need it. -BMR (HDFFV-8766 partially)
//--------------------------------------------------------------------------
-H5File::H5File(hid_t existing_id) : Group()
+H5File::H5File(hid_t existing_id) : Group(), id{existing_id}
{
- id = existing_id;
incRefCount(); // increment number of references to this id
}
@@ -180,9 +179,8 @@ H5File::H5File(hid_t existing_id) : Group()
///\param original - IN: H5File instance to copy
// December 2000
//--------------------------------------------------------------------------
-H5File::H5File(const H5File &original) : Group(original)
+H5File::H5File(const H5File &original) : Group(original), id{original.getId()}
{
- id = original.getId();
incRefCount(); // increment number of references to this id
}
diff --git a/c++/src/H5LcreatProp.cpp b/c++/src/H5LcreatProp.cpp
index 63fe861..3851d56 100644
--- a/c++/src/H5LcreatProp.cpp
+++ b/c++/src/H5LcreatProp.cpp
@@ -121,7 +121,7 @@ LinkCreatPropList::LinkCreatPropList(const hid_t plist_id) : PropList(plist_id)
void
LinkCreatPropList::setCreateIntermediateGroup(bool crt_intmd_group) const
{
- herr_t ret_value = H5Pset_create_intermediate_group(id, (unsigned)crt_intmd_group);
+ herr_t ret_value = H5Pset_create_intermediate_group(id, static_cast<unsigned>(crt_intmd_group));
// Throw exception if H5Pset_create_intermediate_group returns failure
if (ret_value < 0) {
throw PropListIException("setCreateIntermediateGroup", "H5Pset_create_intermediate_group failed");
@@ -146,7 +146,7 @@ LinkCreatPropList::getCreateIntermediateGroup() const
throw PropListIException("getCreateIntermediateGroup", "H5Pget_create_intermediate_group failed");
}
- return ((bool)crt_intmd_group);
+ return static_cast<bool>(crt_intmd_group);
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 065de0c..bb754a2 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -351,7 +351,7 @@ H5Location::getComment(const char *name, size_t buf_size) const
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);
+ ssize_t comment_len = H5Oget_comment_by_name(getId(), name, NULL, 0, H5P_DEFAULT);
// If H5Oget_comment_by_name returns a negative value, raise an exception
if (comment_len < 0) {
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 8b45f79..46e4931 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -113,11 +113,8 @@ PropList::PropList(const PropList &original) : IdComponent(), id(original.id)
// property's id to H5P_DEFAULT.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-PropList::PropList(const hid_t plist_id) : IdComponent()
+PropList::PropList(const hid_t plist_id) : IdComponent(), id{H5P_DEFAULT}
{
- if (plist_id <= 0)
- id = H5P_DEFAULT;
-
H5I_type_t id_type = H5Iget_type(plist_id);
switch (id_type) {
case H5I_GENPROP_CLS:
@@ -633,11 +630,12 @@ PropList::setProperty(const char *name, void *value) const
void
PropList::setProperty(const char *name, const char *charptr) const
{
- herr_t ret_value = H5Pset(id, name, (const void *)charptr);
+ herr_t ret_value = H5Pset(id, name, static_cast<const void *>(charptr));
if (ret_value < 0) {
throw PropListIException(inMemFunc("setProperty"), "H5Pset failed");
}
}
+
//--------------------------------------------------------------------------
// Function: PropList::setProperty
///\brief This is an overloaded member function, provided for convenience.
diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp
index a16061b..53b56fc 100644
--- a/c++/test/dsets.cpp
+++ b/c++/test/dsets.cpp
@@ -23,6 +23,8 @@
***************************************************************************/
+#include <cfloat>
+#include <cmath>
#include <iostream>
using std::cerr;
using std::endl;
@@ -189,9 +191,9 @@ test_simple_io(H5File &file)
SUBTEST("Simple I/O");
- int points[100][200];
- int check[100][200];
- int i, j, n;
+ auto points = new int[100][200];
+ auto check = new int[100][200]();
+ int i, j, n;
// Initialize the dataset
for (i = n = 0; i < 100; i++) {
@@ -233,6 +235,8 @@ test_simple_io(H5File &file)
// clean up and return with success
delete[] tconv_buf;
+ delete[] points;
+ delete[] check;
PASSED();
return 0;
} // end try
@@ -244,6 +248,8 @@ test_simple_io(H5File &file)
// clean up and return with failure
delete[] tconv_buf;
+ delete[] points;
+ delete[] check;
return -1;
}
} // test_simple_io
@@ -408,6 +414,13 @@ filter_bogus(unsigned int flags, size_t cd_nelmts, const unsigned int cd_values[
size_t *buf_size, void **buf)
// H5_ATTR_UNUSED variables caused warning, but taking them out caused failure.
{
+ // Unused
+ (void)flags;
+ (void)cd_nelmts;
+ (void)cd_values;
+ (void)buf_size;
+ (void)buf;
+
return nbytes;
}
@@ -431,8 +444,8 @@ test_compression(H5File &file)
const char *not_supported;
not_supported = " Deflate compression is not enabled.";
#endif /* H5_HAVE_FILTER_DEFLATE */
- int points[100][200];
- int check[100][200];
+ auto points = new int[100][200];
+ auto check = new int[100][200];
hsize_t i, j, n;
// Initialize the dataset
@@ -667,6 +680,8 @@ test_compression(H5File &file)
*/
delete dataset;
delete[] tconv_buf;
+ delete[] points;
+ delete[] check;
return 0;
} // end try
@@ -678,6 +693,8 @@ test_compression(H5File &file)
// clean up and return with failure
delete dataset;
delete[] tconv_buf;
+ delete[] points;
+ delete[] check;
return -1;
}
} // test_compression
@@ -713,6 +730,9 @@ test_nbit_compression(H5File &file)
SUBTEST("N-bit compression (setup)");
+ HDmemset(orig_data, 0, DIM1 * DIM2 * sizeof(s1_t));
+ HDmemset(new_data, 0, DIM1 * DIM2 * sizeof(s1_t));
+
try {
// Define datatypes of members of compound datatype
IntType i_type(PredType::NATIVE_INT);
@@ -1079,7 +1099,7 @@ test_getnativeinfo(H5File &file)
H5O_native_info_t ninfo;
HDmemset(&ninfo, 0, sizeof(ninfo));
dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_HDR);
- verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__);
dataset.close();
// Open the dataset we created above and then close it. This is one
@@ -1087,7 +1107,7 @@ test_getnativeinfo(H5File &file)
dataset = file.openDataSet(DSET_DEFAULT_NAME);
HDmemset(&ninfo, 0, sizeof(ninfo));
dataset.getNativeObjinfo(ninfo, H5O_NATIVE_INFO_ALL);
- verify_val(ninfo.hdr.nchunks, 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(ninfo.hdr.nchunks), 1, "DataSet::getNativeObjinfo", __LINE__, __FILE__);
dataset.close();
PASSED();
@@ -1139,12 +1159,15 @@ test_chunk_cache(const FileAccPropList &fapl)
dapl.getChunkCache(nslots_4, nbytes_4, w0_4);
verify_val(nslots_1, nslots_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
verify_val(nbytes_1, nbytes_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
- verify_val(w0_1, w0_4, "DSetAccPropList::getChunkCache", __LINE__, __FILE__);
+ if (abs(w0_1 - w0_4) > DBL_EPSILON)
+ TestErrPrintf("%d: w0_1 and w0_4 different: w0_1=%f, "
+ "w0_4=%f\n",
+ __LINE__, w0_1, w0_4);
// Set a link access property on dapl to verify property list inheritance
- dapl.setNumLinks((size_t)134);
+ dapl.setNumLinks(134);
size_t nlinks = dapl.getNumLinks();
- verify_val(nlinks, (size_t)134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nlinks), 134, "DSetAccPropList::getNumLinks", __LINE__, __FILE__);
// Make a copy of the external fapl
FileAccPropList fapl_local(fapl);
@@ -1255,7 +1278,8 @@ test_virtual()
// Get the current layout, should be default, H5D_CONTIGUOUS
H5D_layout_t layout = dcpl.getLayout();
- verify_val(layout, H5D_CONTIGUOUS, "DSetCreatPropList::getLayout", __LINE__, __FILE__);
+ verify_val(static_cast<long>(layout), static_cast<long>(H5D_CONTIGUOUS),
+ "DSetCreatPropList::getLayout", __LINE__, __FILE__);
// Create fixed mapping
hsize_t dims[RANK];
@@ -1277,7 +1301,8 @@ test_virtual()
// Get and verify the new layout
layout = dcpl.getLayout();
- verify_val(layout, H5D_VIRTUAL, "DSetCreatPropList::getLayout", __LINE__, __FILE__);
+ verify_val(static_cast<long>(layout), static_cast<long>(H5D_VIRTUAL), "DSetCreatPropList::getLayout",
+ __LINE__, __FILE__);
PASSED();
return 0;
diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp
index 7525c5f..c7c0b65 100644
--- a/c++/test/tarray.cpp
+++ b/c++/test/tarray.cpp
@@ -83,7 +83,8 @@ test_array_compound_array()
for (idxj = 0; idxj < ARRAY1_DIM1; 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;
+ float temp = static_cast<float>(idxi) * 10.0F + static_cast<float>(idxj) * 2.5F +
+ static_cast<float>(idxk);
wdata[idxi][idxj].f[idxk] = temp;
}
} // end for
@@ -242,7 +243,7 @@ test_array_compound_array()
verify_val(ndims, ARRAY1_RANK, "f2_atype_check.getArrayNDims", __LINE__, __FILE__);
// Get the array dimensions
- HDmemset(rdims1, 0, H5S_MAX_RANK);
+ HDmemset(rdims1, 0, sizeof(rdims1));
f2_atype_check.getArrayDims(rdims1);
// Check the array dimensions
@@ -288,7 +289,7 @@ test_array_compound_array()
/*
* Helper routine to demonstrate the issue in HDFFV-9562
*/
-H5::DataType
+static H5::DataType
getArr()
{
hsize_t *dims = new hsize_t;
@@ -388,10 +389,11 @@ test_array_info()
for (idxj = 0; idxj < ARRAY1_DIM1; 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;
+ float temp = static_cast<float>(idxi) * 10.0F + static_cast<float>(idxj) * 2.5F +
+ static_cast<float>(idxk);
wdata[idxi][idxj].f[idxk] = temp;
}
- } // end for
+ }
try {
// Create File
diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp
index adaa237..45ccc98 100644
--- a/c++/test/tattr.cpp
+++ b/c++/test/tattr.cpp
@@ -17,6 +17,8 @@
C attribute interface (H5A)
***************************************************************************/
+#include <cfloat>
+#include <cmath>
#include <iostream>
using std::cerr;
using std::endl;
@@ -93,7 +95,7 @@ struct attr4_struct {
const H5std_string ATTR5_NAME("Attr5");
const int ATTR5_RANK = 0;
-float attr_data5 = (float)-5.123; // Test data for 5th attribute
+float attr_data5 = -5.123f; // Test data for 5th attribute
/* Info for another attribute */
const H5std_string ATTR1A_NAME("Attr1_a");
@@ -208,7 +210,7 @@ test_attr_basic_write()
// Check storage size for attribute
hsize_t attr_size = gr_attr.getStorageSize();
- verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
+ verify_val(static_cast<long>(attr_size), static_cast<long>(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
"Attribute::getStorageSize", __LINE__, __FILE__);
// Try to create the same attribute again (should fail)
@@ -227,7 +229,7 @@ test_attr_basic_write()
// Check storage size for attribute
attr_size = gr_attr.getStorageSize();
- verify_val((long)attr_size, (long)(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
+ verify_val(static_cast<long>(attr_size), static_cast<long>(ATTR2_DIM1 * ATTR2_DIM2 * sizeof(int)),
"Attribute::getStorageSize", __LINE__, __FILE__);
PASSED();
@@ -298,8 +300,10 @@ test_attr_getname()
ssize_t name_size = 0; // actual length of attribute name
name_size = fattr1.getName(fattr1_name, buf_size + 1);
CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
- verify_val((size_t)name_size, FATTR1_NAME.length(), "Attribute::getName", __LINE__, __FILE__);
- verify_val((const char *)fattr1_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
+ verify_val(static_cast<size_t>(name_size), FATTR1_NAME.length(), "Attribute::getName", __LINE__,
+ __FILE__);
+ verify_val(const_cast<const char *>(fattr1_name), FATTR1_NAME, "Attribute::getName", __LINE__,
+ __FILE__);
delete[] fattr1_name;
// 2. With arbitrary buf_size that is smaller than the name's length.
@@ -310,9 +314,10 @@ test_attr_getname()
HDmemset(fattr1_name, 0, buf_size + 1);
name_size = fattr1.getName(fattr1_name, buf_size + 1);
CHECK(name_size, FAIL, "Attribute::getName", __LINE__, __FILE__);
- verify_val((size_t)name_size, FATTR1_NAME.size(), "Attribute::getName", __LINE__, __FILE__);
- verify_val((const char *)fattr1_name, (const char *)short_name, "Attribute::getName", __LINE__,
+ verify_val(static_cast<size_t>(name_size), FATTR1_NAME.size(), "Attribute::getName", __LINE__,
__FILE__);
+ verify_val(const_cast<const char *>(fattr1_name), const_cast<const char *>(short_name),
+ "Attribute::getName", __LINE__, __FILE__);
delete[] fattr1_name;
// 3. With a buf_size that equals the name's length.
@@ -525,7 +530,7 @@ test_attr_basic_read()
H5O_info2_t oinfo;
HDmemset(&oinfo, 0, sizeof(oinfo));
dataset.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS);
- verify_val(oinfo.num_attrs, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(oinfo.num_attrs), 3, "DataSet::getObjinfo", __LINE__, __FILE__);
// Open an attribute for the dataset
Attribute ds_attr = dataset.openAttribute(ATTR1_NAME);
@@ -553,7 +558,7 @@ test_attr_basic_read()
// Verify the correct number of attributes another way
HDmemset(&oinfo, 0, sizeof(oinfo));
group.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS);
- verify_val(oinfo.num_attrs, 1, "Group::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(oinfo.num_attrs), 1, "Group::getObjinfo", __LINE__, __FILE__);
// Open an attribute for the group
Attribute gr_attr = group.openAttribute(ATTR2_NAME);
@@ -678,10 +683,10 @@ test_attr_compound_read()
H5O_info2_t oinfo;
HDmemset(&oinfo, 0, sizeof(oinfo));
dataset.getObjinfo(oinfo, H5O_INFO_NUM_ATTRS);
- verify_val(oinfo.num_attrs, 1, "DataSet::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(oinfo.num_attrs), 1, "DataSet::getObjinfo", __LINE__, __FILE__);
// Open 1st attribute for the dataset
- Attribute attr = dataset.openAttribute((unsigned)0);
+ Attribute attr = dataset.openAttribute(static_cast<unsigned>(0));
/* Verify Dataspace */
@@ -695,14 +700,17 @@ test_attr_compound_read()
// Get the dims of the dataspace and verify them
int ndims = space.getSimpleExtentDims(dims);
verify_val(ndims, ATTR4_RANK, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- verify_val((long)dims[0], (long)ATTR4_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- verify_val((long)dims[1], (long)ATTR4_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val(static_cast<long>(dims[0]), static_cast<long>(ATTR4_DIM1),
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val(static_cast<long>(dims[1]), static_cast<long>(ATTR4_DIM2),
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
// Get the class of the datatype that is used by attr
H5T_class_t type_class = attr.getTypeClass();
// Verify that the type is of compound datatype
- verify_val(type_class, H5T_COMPOUND, "Attribute::getTypeClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_COMPOUND), "Attribute::getTypeClass",
+ __LINE__, __FILE__);
// Get the compound datatype
CompType datatype = attr.getCompType();
@@ -734,11 +742,13 @@ test_attr_compound_read()
// Get and verify the type class of the first member
type_class = datatype.getMemberClass(0);
- verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_INTEGER), "DataType::getMemberClass",
+ __LINE__, __FILE__);
// Get and verify the order of this member's type
IntType i_type = datatype.getMemberIntType(0);
H5T_order_t order = i_type.getOrder();
- verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_INT.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
// Get and verify the size of this member's type
size = i_type.getSize();
@@ -746,21 +756,25 @@ test_attr_compound_read()
// Get and verify class, order, and size of the second member's type
type_class = datatype.getMemberClass(1);
- verify_val(type_class, H5T_FLOAT, "DataType::getMemberClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_FLOAT), "DataType::getMemberClass",
+ __LINE__, __FILE__);
FloatType f_type = datatype.getMemberFloatType(1);
order = f_type.getOrder();
- verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_DOUBLE.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
size = f_type.getSize();
verify_val(size, PredType::NATIVE_DOUBLE.getSize(), "DataType::getSize", __LINE__, __FILE__);
// Get and verify class, order, and size of the third member's type
type_class = datatype.getMemberClass(2);
- verify_val(type_class, H5T_INTEGER, "DataType::getMemberClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_INTEGER), "DataType::getMemberClass",
+ __LINE__, __FILE__);
// Note: H5T_INTEGER is correct here!
StrType s_type = datatype.getMemberStrType(2);
order = s_type.getOrder();
- verify_val(order, PredType::NATIVE_SCHAR.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_SCHAR.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
size = s_type.getSize();
verify_val(size, PredType::NATIVE_SCHAR.getSize(), "DataType::getSize", __LINE__, __FILE__);
@@ -902,15 +916,18 @@ test_attr_scalar_read()
// Read attribute information
float read_data2 = 0.0; // Buffer for reading 1st attribute
ds_attr.read(PredType::NATIVE_FLOAT, &read_data2);
- if (HDfabs(read_data2 - attr_data5) > FP_EPSILON)
- verify_val(read_data2, attr_data5, FP_EPSILON, "Attribute::read", __LINE__, __FILE__);
+ if (abs(read_data2 - attr_data5) > FLT_EPSILON)
+ TestErrPrintf("%d: attribute data different: read_data2=%f, "
+ "attr_data5=%f\n",
+ __LINE__, static_cast<double>(read_data2), static_cast<double>(attr_data5));
// Get the dataspace of the attribute
DataSpace att_space = ds_attr.getSpace();
// Make certain the dataspace is scalar
H5S_class_t space_type = att_space.getSimpleExtentType();
- verify_val(space_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(space_type), static_cast<long>(H5S_SCALAR),
+ "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
PASSED();
} // end try block
@@ -1029,7 +1046,7 @@ test_attr_mult_read()
verify_val(num_attrs, 3, "DataSet::getNumAttrs", __LINE__, __FILE__);
// Open 1st attribute for the dataset
- Attribute attr = dataset.openAttribute((unsigned)0);
+ Attribute attr = dataset.openAttribute(static_cast<unsigned>(0));
/* Verify Dataspace */
@@ -1042,10 +1059,10 @@ test_attr_mult_read()
// Get the dims of the dataspace and verify them
hsize_t dims[ATTR_MAX_DIMS]; // Attribute dimensions
- int ndims = space.getSimpleExtentDims(dims);
- if ((long)dims[0] != (long)ATTR1_DIM1)
+ (void)space.getSimpleExtentDims(dims);
+ if (dims[0] != ATTR1_DIM1)
TestErrPrintf("%d:attribute dimensions different: dims[0]=%d, should be %llu\n", __LINE__,
- (int)dims[0], ATTR1_DIM1);
+ static_cast<int>(dims[0]), ATTR1_DIM1);
/* Verify Datatype */
@@ -1053,14 +1070,16 @@ test_attr_mult_read()
H5T_class_t type_class = attr.getTypeClass();
// Verify that the type is of integer datatype
- verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_INTEGER), "Attribute::getTypeClass",
+ __LINE__, __FILE__);
// Get the integer datatype
IntType i_type1 = attr.getIntType();
// Get and verify the order of this type
H5T_order_t order = i_type1.getOrder();
- verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_INT.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
// Get and verify the size of this type
size_t size = i_type1.getSize();
@@ -1083,7 +1102,7 @@ test_attr_mult_read()
space.close();
// Open 2nd attribute for the dataset
- attr = dataset.openAttribute((unsigned)1);
+ attr = dataset.openAttribute(static_cast<unsigned>(1));
/* Verify Dataspace */
@@ -1095,10 +1114,12 @@ test_attr_mult_read()
verify_val(rank, ATTR2_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Get the dims of the dataspace and verify them
- ndims = space.getSimpleExtentDims(dims);
+ (void)space.getSimpleExtentDims(dims);
- verify_val((long)dims[0], (long)ATTR2_DIM1, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
- verify_val((long)dims[1], (long)ATTR2_DIM2, "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val(static_cast<long>(dims[0]), static_cast<long>(ATTR2_DIM1),
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
+ verify_val(static_cast<long>(dims[1]), static_cast<long>(ATTR2_DIM2),
+ "DataSpace::getSimpleExtentDims", __LINE__, __FILE__);
/* Verify Datatype */
@@ -1106,14 +1127,16 @@ test_attr_mult_read()
type_class = attr.getTypeClass();
// Verify that the type is of integer datatype
- verify_val(type_class, H5T_INTEGER, "Attribute::getTypeClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_INTEGER), "Attribute::getTypeClass",
+ __LINE__, __FILE__);
// Get the integer datatype
IntType i_type2 = attr.getIntType();
// Get and verify the order of this type
order = i_type2.getOrder();
- verify_val(order, PredType::NATIVE_INT.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_INT.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
// Get and verify the size of this type
size = i_type2.getSize();
@@ -1138,7 +1161,7 @@ test_attr_mult_read()
space.close();
// Open 3rd attribute for the dataset
- attr = dataset.openAttribute((unsigned)2);
+ attr = dataset.openAttribute(static_cast<unsigned>(2));
/* Verify Dataspace */
@@ -1150,10 +1173,13 @@ test_attr_mult_read()
verify_val(rank, ATTR3_RANK, "DataSpace::getSimpleExtentNdims", __LINE__, __FILE__);
// Get the dims of the dataspace and verify them
- ndims = space.getSimpleExtentDims(dims);
- verify_val((long)dims[0], (long)ATTR3_DIM1, "attribute dimensions", __FILE__, __LINE__);
- verify_val((long)dims[1], (long)ATTR3_DIM2, "attribute dimensions", __FILE__, __LINE__);
- verify_val((long)dims[2], (long)ATTR3_DIM3, "attribute dimensions", __FILE__, __LINE__);
+ (void)space.getSimpleExtentDims(dims);
+ verify_val(static_cast<long>(dims[0]), static_cast<long>(ATTR3_DIM1), "attribute dimensions",
+ __FILE__, __LINE__);
+ verify_val(static_cast<long>(dims[1]), static_cast<long>(ATTR3_DIM2), "attribute dimensions",
+ __FILE__, __LINE__);
+ verify_val(static_cast<long>(dims[2]), static_cast<long>(ATTR3_DIM3), "attribute dimensions",
+ __FILE__, __LINE__);
/* Verify Datatype */
@@ -1161,14 +1187,16 @@ test_attr_mult_read()
type_class = attr.getTypeClass();
// Verify that the type is of compound datatype
- verify_val(type_class, H5T_FLOAT, "Attribute::getTypeClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_FLOAT), "Attribute::getTypeClass",
+ __LINE__, __FILE__);
// Get the double datatype
FloatType f_type = attr.getFloatType();
// Get and verify the order of this type
order = f_type.getOrder();
- verify_val(order, PredType::NATIVE_DOUBLE.getOrder(), "DataType::getOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(order), static_cast<long>(PredType::NATIVE_DOUBLE.getOrder()),
+ "DataType::getOrder", __LINE__, __FILE__);
// Get and verify the size of this type
size = f_type.getSize();
@@ -1181,7 +1209,7 @@ test_attr_mult_read()
for (i = 0; i < ATTR3_DIM1; i++)
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])
+ if (abs(attr_data3[i][j][k] - read_data3[i][j][k]) > DBL_EPSILON)
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]);
@@ -1230,7 +1258,7 @@ test_attr_delete()
verify_val(num_attrs, 1, "H5File::getNumAttrs", __LINE__, __FILE__);
// Verify the name of the only file attribute left
- Attribute fattr = fid1.openAttribute((unsigned)0);
+ Attribute fattr = fid1.openAttribute(static_cast<unsigned>(0));
attr_name = fattr.getName();
verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__);
fattr.close();
@@ -1270,7 +1298,7 @@ test_attr_delete()
verify_val(num_attrs, 2, "DataSet::getNumAttrs", __LINE__, __FILE__);
// Open 1st attribute for the dataset
- Attribute attr = dataset.openAttribute((unsigned)0);
+ Attribute attr = dataset.openAttribute(static_cast<unsigned>(0));
// Verify Name
attr_name = attr.getName();
@@ -1280,7 +1308,7 @@ test_attr_delete()
attr.close();
// Open last (formally 3rd) attribute for the dataset
- attr = dataset.openAttribute((unsigned)1);
+ attr = dataset.openAttribute(static_cast<unsigned>(1));
// Verify Name
attr_name = attr.getName();
@@ -1296,7 +1324,7 @@ test_attr_delete()
verify_val(num_attrs, 1, "DataSet::getNumAttrs", __LINE__, __FILE__);
// Open the only attribute for the dataset (formally 3rd)
- attr = dataset.openAttribute((unsigned)0);
+ attr = dataset.openAttribute(static_cast<unsigned>(0));
// Verify Name
attr_name = attr.getName();
@@ -1370,7 +1398,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 1, "DataType::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 1, "DataType::getObjinfo", __LINE__, __FILE__);
#endif
// Create dataspace for dataset
@@ -1381,7 +1409,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 2, "H5File::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 2, "H5File::getObjinfo", __LINE__, __FILE__);
#endif
// Create attribute on dataset
@@ -1390,7 +1418,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::getObjinfo", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 3, "DataSet::getObjinfo", __LINE__, __FILE__);
#endif
// Close attribute
@@ -1402,8 +1430,8 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 2, "DataSet::getObjinfo after DataSet::removeAttr", __LINE__,
- __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 2, "DataSet::getObjinfo after DataSet::removeAttr",
+ __LINE__, __FILE__);
#endif
// Create attribute on dataset
@@ -1412,7 +1440,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::createAttribute", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 3, "DataSet::createAttribute", __LINE__, __FILE__);
#endif
// Write data into the attribute
@@ -1449,7 +1477,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 3, "DataSet::openAttribute", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 3, "DataSet::openAttribute", __LINE__, __FILE__);
#endif
} // end of second enclosing
@@ -1459,7 +1487,7 @@ test_attr_dtype_shared()
#ifndef H5_NO_DEPRECATED_SYMBOLS
// Check reference count on named datatype
fid1.getObjinfo(TYPE1_NAME, statbuf);
- verify_val((int)statbuf.nlink, 1, "H5File::unlink", __LINE__, __FILE__);
+ verify_val(static_cast<int>(statbuf.nlink), 1, "H5File::unlink", __LINE__, __FILE__);
#endif
// Unlink the named datatype
@@ -1470,7 +1498,8 @@ test_attr_dtype_shared()
// Check size of file
filesize = h5_get_file_size(FILE_DTYPE.c_str(), H5P_DEFAULT);
- verify_val((long)filesize, (long)empty_filesize, "Checking file size", __LINE__, __FILE__);
+ verify_val(static_cast<long>(filesize), static_cast<long>(empty_filesize), "Checking file size",
+ __LINE__, __FILE__);
PASSED();
} // end try block
@@ -1806,7 +1835,8 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl)
// Get creation order indexing on object
unsigned crt_order_flags = 0;
crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)0, "DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
+ verify_val(static_cast<long>(crt_order_flags), 0, "DSetCreatPropList::getAttrCrtOrder", __LINE__,
+ __FILE__);
// Setting invalid combination of a attribute order creation order
// indexing on should fail
@@ -1825,7 +1855,7 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl)
// verify them
dcpl.setAttrCrtOrder(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED);
crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
+ verify_val(crt_order_flags, static_cast<unsigned>(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
"DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
// Create dataspace for dataset
@@ -1861,7 +1891,7 @@ test_attr_corder_create_basic(FileCreatPropList &fcpl, FileAccPropList &fapl)
// Query the attribute creation properties
crt_order_flags = dcpl.getAttrCrtOrder();
- verify_val(crt_order_flags, (unsigned)(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
+ verify_val(crt_order_flags, static_cast<unsigned>(H5P_CRT_ORDER_TRACKED | H5P_CRT_ORDER_INDEXED),
"DSetCreatPropList::getAttrCrtOrder", __LINE__, __FILE__);
PASSED();
diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp
index 2170a9d..c27171b 100644
--- a/c++/test/tcompound.cpp
+++ b/c++/test/tcompound.cpp
@@ -101,11 +101,11 @@ test_compound_2()
SUBTEST("Compound Element Reordering");
try {
// Sizes should be the same, but be careful just in case
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
s_ptr->b = i * 8 + 1;
s_ptr->c[0] = i * 8 + 2;
@@ -115,7 +115,7 @@ test_compound_2()
s_ptr->d = i * 8 + 6;
s_ptr->e = i * 8 + 7;
}
- memcpy(buf, orig, nelmts * sizeof(src_typ_t));
+ HDmemcpy(buf, orig, nelmts * sizeof(src_typ_t));
// Build hdf5 datatypes
array_dt = new ArrayType(PredType::NATIVE_INT, 1, &four);
@@ -142,12 +142,12 @@ test_compound_2()
array_dt->close();
// Perform the conversion
- st.convert(dt, (size_t)nelmts, buf, bkg);
+ st.convert(dt, static_cast<size_t>(nelmts), buf, bkg);
// Compare results
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
- d_ptr = ((dst_typ_t *)buf) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
+ d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
@@ -214,11 +214,11 @@ test_compound_3()
SUBTEST("Compound Datatype Subset Conversions");
try {
/* Initialize */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
s_ptr->b = i * 8 + 1;
s_ptr->c[0] = i * 8 + 2;
@@ -253,12 +253,12 @@ test_compound_3()
array_dt->close();
/* Perform the conversion */
- st.convert(dt, (size_t)nelmts, buf, bkg);
+ st.convert(dt, static_cast<size_t>(nelmts), buf, bkg);
/* Compare results */
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
- d_ptr = ((dst_typ_t *)buf) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
+ d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
if (s_ptr->a != d_ptr->a || s_ptr->c[0] != d_ptr->c[0] || s_ptr->c[1] != d_ptr->c[1] ||
s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] || s_ptr->e != d_ptr->e) {
H5_FAILED();
@@ -268,8 +268,8 @@ test_compound_3()
<< ", e=" << s_ptr->e << "}" << endl;
cerr << " dst={a=" << d_ptr->a << ", c=[" << d_ptr->c[0] << "," << d_ptr->c[1] << ","
<< d_ptr->c[2] << "," << d_ptr->c[3] << "], e=" << d_ptr->e << "}" << endl;
- } // if
- } // for
+ }
+ }
/* Release resources */
HDfree(buf);
@@ -329,11 +329,11 @@ test_compound_4()
SUBTEST("Compound Element Shrinking & Reordering");
try {
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->a = i * 8 + 0;
s_ptr->b = (i * 8 + 1) & 0x7fff;
s_ptr->c[0] = i * 8 + 2;
@@ -370,12 +370,12 @@ test_compound_4()
array_dt->close();
/* Perform the conversion */
- st.convert(dt, (size_t)nelmts, buf, bkg);
+ st.convert(dt, static_cast<size_t>(nelmts), buf, bkg);
/* Compare results */
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
- d_ptr = ((dst_typ_t *)buf) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
+ d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
if (s_ptr->a != d_ptr->a || s_ptr->b != d_ptr->b || s_ptr->c[0] != d_ptr->c[0] ||
s_ptr->c[1] != d_ptr->c[1] || s_ptr->c[2] != d_ptr->c[2] || s_ptr->c[3] != d_ptr->c[3] ||
s_ptr->d != d_ptr->d || s_ptr->e != d_ptr->e) {
@@ -473,8 +473,8 @@ test_compound_5()
/* Convert data */
memcpy(buf, src, sizeof(src));
- src_type.convert(dst_type, (size_t)2, buf, bkg);
- dst = (dst_typ_t *)buf;
+ src_type.convert(dst_type, 2, buf, bkg);
+ dst = static_cast<dst_typ_t *>(buf);
/* Cleanup */
src_type.close();
@@ -540,11 +540,11 @@ test_compound_6()
SUBTEST("Compound Element Growing");
try {
/* Sizes should be the same, but be careful just in case */
- buf = (unsigned char *)HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));
- bkg = (unsigned char *)HDmalloc(nelmts * sizeof(dst_typ_t));
- orig = (unsigned char *)HDmalloc(nelmts * sizeof(src_typ_t));
+ buf = static_cast<unsigned char *>(HDmalloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t))));
+ bkg = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(dst_typ_t)));
+ orig = static_cast<unsigned char *>(HDmalloc(nelmts * sizeof(src_typ_t)));
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
s_ptr->b = (i * 8 + 1) & 0x7fff;
s_ptr->d = (i * 8 + 6) & 0x7fff;
}
@@ -560,19 +560,19 @@ test_compound_6()
dt.insertMember("d", HOFFSET(dst_typ_t, d), PredType::NATIVE_LONG);
/* Perform the conversion */
- st.convert(dt, (size_t)nelmts, buf, bkg);
+ st.convert(dt, static_cast<size_t>(nelmts), buf, bkg);
/* Compare results */
for (i = 0; i < nelmts; i++) {
- s_ptr = ((src_typ_t *)orig) + i;
- d_ptr = ((dst_typ_t *)buf) + i;
+ s_ptr = (reinterpret_cast<src_typ_t *>(orig)) + i;
+ d_ptr = (reinterpret_cast<dst_typ_t *>(buf)) + i;
if (s_ptr->b != d_ptr->b || s_ptr->d != d_ptr->d) {
H5_FAILED();
cerr << " i=" << i << endl;
cerr << " src={b=" << s_ptr->b << ", d=" << s_ptr->d << "}" << endl;
cerr << " dst={b=" << d_ptr->b << ", d=" << d_ptr->d << "}" << endl;
- } // if
- } // for
+ }
+ }
/* Release resources */
HDfree(buf);
@@ -715,22 +715,22 @@ test_compound_set_size()
// verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__);
// Expand the type, and verify that it became unpacked
- dtype.setSize((size_t)33);
+ dtype.setSize(33);
// packed = dtype.packed(); // not until C library provides API
// verify_val(packed, FALSE, "DataType::packed", __LINE__, __FILE__);
// Verify setSize() actually set size
size_t new_size = dtype.getSize();
- verify_val(new_size, (size_t)33, "DataType::getSize", __LINE__, __FILE__);
+ verify_val(static_cast<long>(new_size), 33, "DataType::getSize", __LINE__, __FILE__);
// Shrink the type, and verify that it became packed
- dtype.setSize((size_t)32);
+ dtype.setSize(32);
// packed = dtype.packed(); // not until C library provides API
// verify_val(packed, TRUE, "DataType::packed", __LINE__, __FILE__);
// Verify setSize() actually set size again
new_size = dtype.getSize();
- verify_val(new_size, (size_t)32, "DataType::getSize", __LINE__, __FILE__);
+ verify_val(static_cast<long>(new_size), 32, "DataType::getSize", __LINE__, __FILE__);
/* Close types and file */
dtype_tmp.close();
diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp
index 257233e..5a78133 100644
--- a/c++/test/tdspl.cpp
+++ b/c++/test/tdspl.cpp
@@ -61,11 +61,11 @@ test_transfplist()
// Find out the length of the transform expression, allocate the buffer
// for it, then read and verify the expression from the copied plist
ssize_t tran_len = dxpl_c_to_f_copy.getDataTransform(NULL);
- char * c_to_f_read = (char *)HDmalloc(tran_len + 1);
+ char * c_to_f_read = static_cast<char *>(HDmalloc(tran_len + 1));
HDmemset(c_to_f_read, 0, tran_len + 1);
dxpl_c_to_f_copy.getDataTransform(c_to_f_read, tran_len + 1);
- verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform",
- __LINE__, __FILE__);
+ verify_val(const_cast<const char *>(c_to_f_read), const_cast<const char *>(c_to_f),
+ "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
HDfree(c_to_f_read);
//
@@ -76,26 +76,26 @@ test_transfplist()
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size [default=0])
tran_len = dxpl_c_to_f.getDataTransform(NULL);
- c_to_f_read = (char *)HDmalloc(tran_len + 1);
+ c_to_f_read = static_cast<char *>(HDmalloc(tran_len + 1));
HDmemset(c_to_f_read, 0, tran_len + 1);
dxpl_c_to_f.getDataTransform(c_to_f_read, tran_len + 1);
- verify_val((const char *)c_to_f_read, (const char *)c_to_f, "DSetMemXferPropList::getDataTransform",
- __LINE__, __FILE__);
+ verify_val(const_cast<const char *>(c_to_f_read), const_cast<const char *>(c_to_f),
+ "DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
HDfree(c_to_f_read);
// Get and verify the expression with:
// H5std_string DSetMemXferPropList::getDataTransform()
H5std_string simple_read = dxpl_simple.getDataTransform();
- verify_val((const char *)simple_read.c_str(), (const char *)simple,
+ verify_val(const_cast<const char *>(simple_read.c_str()), const_cast<const char *>(simple),
"DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
// Get and verify the expression with:
// ssize_t getDataTransform(char* exp, const size_t buf_size)
tran_len = dxpl_utrans_inv.getDataTransform(NULL, 0);
- char *utrans_inv_read = (char *)HDmalloc(tran_len + 1);
+ char *utrans_inv_read = static_cast<char *>(HDmalloc(tran_len + 1));
HDmemset(utrans_inv_read, 0, tran_len + 1);
dxpl_utrans_inv.getDataTransform(utrans_inv_read, tran_len + 1);
- verify_val((const char *)utrans_inv_read, (const char *)utrans_inv,
+ verify_val(const_cast<const char *>(utrans_inv_read), const_cast<const char *>(utrans_inv),
"DSetMemXferPropList::getDataTransform", __LINE__, __FILE__);
HDfree(utrans_inv_read);
diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp
index 255fc30..15bad64 100644
--- a/c++/test/tfile.cpp
+++ b/c++/test/tfile.cpp
@@ -31,14 +31,14 @@ using namespace H5;
#include "h5test.h"
#include "h5cpputil.h" // C++ utilility header file
-const hsize_t F1_USERBLOCK_SIZE = (hsize_t)0;
+const hsize_t F1_USERBLOCK_SIZE = 0;
const size_t F1_OFFSET_SIZE = sizeof(haddr_t);
const size_t F1_LENGTH_SIZE = sizeof(hsize_t);
const unsigned F1_SYM_LEAF_K = 4;
const unsigned F1_SYM_INTERN_K = 16;
const H5std_string FILE1("tfile1.h5");
-const hsize_t F2_USERBLOCK_SIZE = (hsize_t)512;
+const hsize_t F2_USERBLOCK_SIZE = 512;
const size_t F2_OFFSET_SIZE = 8;
const size_t F2_LENGTH_SIZE = 8;
const unsigned F2_SYM_LEAF_K = 8;
@@ -46,7 +46,7 @@ const unsigned F2_SYM_INTERN_K = 32;
const unsigned F2_ISTORE = 64;
const H5std_string FILE2("tfile2.h5");
-const hsize_t F3_USERBLOCK_SIZE = (hsize_t)0;
+const hsize_t F3_USERBLOCK_SIZE = 0;
const size_t F3_OFFSET_SIZE = F2_OFFSET_SIZE;
const size_t F3_LENGTH_SIZE = F2_LENGTH_SIZE;
const unsigned F3_SYM_LEAF_K = F2_SYM_LEAF_K;
@@ -153,8 +153,8 @@ test_file_create()
FileCreatPropList tmpl1 = file1->getCreatePlist();
hsize_t ublock = tmpl1.getUserblock();
- verify_val((long)ublock, (long)F1_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
- __FILE__);
+ verify_val(static_cast<long>(ublock), static_cast<long>(F1_USERBLOCK_SIZE),
+ "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; // file-creation parameters
tmpl1.getSizes(parm1, parm2);
@@ -209,8 +209,8 @@ test_file_create()
// Get the file-creation parameters
hsize_t ublock = tmpl1->getUserblock();
- verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
- __FILE__);
+ verify_val(static_cast<long>(ublock), static_cast<long>(F2_USERBLOCK_SIZE),
+ "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; // file-creation parameters
tmpl1->getSizes(parm1, parm2);
@@ -242,8 +242,8 @@ test_file_create()
// Get the file-creation parameters
ublock = tmpl1->getUserblock();
- verify_val((long)ublock, (long)F3_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
- __FILE__);
+ verify_val(static_cast<long>(ublock), static_cast<long>(F3_USERBLOCK_SIZE),
+ "FileCreatPropList::getUserblock", __LINE__, __FILE__);
tmpl1->getSizes(parm1, parm2);
verify_val(parm1, F3_OFFSET_SIZE, "FileCreatPropList::getSizes", __LINE__, __FILE__);
@@ -300,8 +300,8 @@ test_file_open()
// Get the file-creation parameters
hsize_t ublock = tmpl1.getUserblock();
- verify_val((long)ublock, (long)F2_USERBLOCK_SIZE, "FileCreatPropList::getUserblock", __LINE__,
- __FILE__);
+ verify_val(static_cast<long>(ublock), static_cast<long>(F2_USERBLOCK_SIZE),
+ "FileCreatPropList::getUserblock", __LINE__, __FILE__);
size_t parm1, parm2; // file-creation parameters
tmpl1.getSizes(parm1, parm2);
@@ -645,7 +645,8 @@ test_file_attribute()
// Get the class of a file attribute's datatype
H5T_class_t atclass = fattr1.getTypeClass();
- verify_val(atclass, H5T_FLOAT, "Attribute::getTypeClass()", __LINE__, __FILE__);
+ verify_val(static_cast<long>(atclass), static_cast<long>(H5T_FLOAT), "Attribute::getTypeClass()",
+ __LINE__, __FILE__);
// Get and verify the number of attributes attached to a file
int n_attrs = file5.getNumAttrs();
@@ -896,9 +897,9 @@ test_file_info()
// Get the file's version information.
H5F_info2_t finfo;
tempfile.getFileInfo(finfo);
- verify_val(finfo.super.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.super.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
// Close the file.
tempfile.close();
@@ -910,9 +911,10 @@ test_file_info()
fcpl.getFileSpaceStrategy(out_strategy, out_persist, out_threshold);
// Verify file space information.
- verify_val(out_strategy, H5F_FSPACE_STRATEGY_FSM_AGGR, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(out_strategy), static_cast<long>(H5F_FSPACE_STRATEGY_FSM_AGGR),
+ "H5File::getFileInfo", __LINE__, __FILE__);
verify_val(out_persist, FALSE, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(out_threshold, 1, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(out_threshold), 1, "H5File::getFileInfo", __LINE__, __FILE__);
/* Retrieve file space page size */
hsize_t out_fsp_psize = fcpl.getFileSpacePagesize();
@@ -943,9 +945,9 @@ test_file_info()
// Get the file's version information.
file7.getFileInfo(finfo);
- verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.super.version), 2, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
// Close the file.
file7.close();
@@ -958,9 +960,9 @@ test_file_info()
// Get the file's version information.
file7.getFileInfo(finfo);
- verify_val(finfo.super.version, 2, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.free.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
- verify_val(finfo.sohm.version, 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.super.version), 2, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.free.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
+ verify_val(static_cast<long>(finfo.sohm.version), 0, "H5File::getFileInfo", __LINE__, __FILE__);
// Retrieve the property values & check them.
hsize_t userblock = fcpl2.getUserblock();
@@ -986,7 +988,8 @@ test_file_info()
// Get and verify the file space info from the creation property list */
fcpl2.getFileSpaceStrategy(out_strategy, out_persist, out_threshold);
- verify_val(out_strategy, strategy, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__);
+ verify_val(static_cast<long>(out_strategy), static_cast<long>(strategy),
+ "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__);
verify_val(out_persist, persist, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__);
verify_val(out_threshold, threshold, "FileCreatPropList::getFileSpaceStrategy", __LINE__, __FILE__);
diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp
index 9952e68..5808136 100644
--- a/c++/test/th5s.cpp
+++ b/c++/test/th5s.cpp
@@ -73,7 +73,7 @@ struct space4_struct {
unsigned u;
float f;
char c2;
-} space4_data = {'v', 987123, (float)-3.14, 'g'}; /* Test data for 4th dataspace */
+} space4_data = {'v', 987123, -3.14f, 'g'}; /* Test data for 4th dataspace */
/* Null dataspace */
int space5_data = 7;
@@ -118,7 +118,7 @@ test_h5s_basic()
// Get simple extent npoints of the dataspace sid1 and verify it
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, (long)(SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3),
+ verify_val(static_cast<long>(n), SPACE1_DIM1 * SPACE1_DIM2 * SPACE1_DIM3,
"DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid1 and verify it
@@ -140,7 +140,7 @@ test_h5s_basic()
// Get simple extent npoints of dataspace sid2 and verify it
n = sid2.getSimpleExtentNpoints();
- verify_val((long)n, (long)(SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4),
+ verify_val(static_cast<long>(n), SPACE2_DIM1 * SPACE2_DIM2 * SPACE2_DIM3 * SPACE2_DIM4,
"DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of dataspace sid2 and verify it
@@ -200,6 +200,7 @@ test_h5s_basic()
// CHECK_I(ret, "H5Fclose"); // leave this here, later, fake a failure
// in the p_close see how this will handle it. - BMR
+ // When running in valgrind, this PASSED macro will be missed
PASSED();
} // end of try block
@@ -248,7 +249,7 @@ test_h5s_scalar_write()
// n = H5Sget_simple_extent_npoints(sid1);
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
int rank; // Logical rank of dataspace
rank = sid1.getSimpleExtentNdims();
@@ -263,7 +264,8 @@ test_h5s_scalar_write()
// Verify extent type
H5S_class_t ext_type; // Extent type
ext_type = sid1.getSimpleExtentType();
- verify_val(ext_type, H5S_SCALAR, "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(ext_type), static_cast<long>(H5S_SCALAR),
+ "DataSpace::getSimpleExtentType", __LINE__, __FILE__);
// Create and write a dataset
DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1);
@@ -314,7 +316,7 @@ test_h5s_scalar_read()
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
@@ -371,7 +373,7 @@ test_h5s_null()
hssize_t n; // Number of dataspace elements
n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n), 0, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Create a dataset
DataSet dataset = fid1.createDataSet("Dataset1", PredType::NATIVE_UINT, sid1);
@@ -436,7 +438,7 @@ test_h5s_compound_scalar_write()
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
@@ -496,7 +498,7 @@ test_h5s_compound_scalar_read()
// Get the number of dataspace elements
hssize_t n = sid1.getSimpleExtentNpoints();
- verify_val((long)n, 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n), 1, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Get the logical rank of the dataspace
int ndims = sid1.getSimpleExtentNdims();
diff --git a/c++/test/titerate.cpp b/c++/test/titerate.cpp
index 17620ca..b6a9436 100644
--- a/c++/test/titerate.cpp
+++ b/c++/test/titerate.cpp
@@ -67,7 +67,8 @@ typedef struct {
iter_enum command; /* The type of return value */
} iter_info;
-int iter_strcmp(const void *s1, const void *s2);
+static int iter_strcmp(const void *s1, const void *s2);
+static void printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname);
/*-------------------------------------------------------------------------
* Function: iter_strcmp
@@ -75,10 +76,10 @@ int iter_strcmp(const void *s1, const void *s2);
* Purpose String comparison routine for qsort
*-------------------------------------------------------------------------
*/
-int
+static int
iter_strcmp(const void *s1, const void *s2)
{
- return (HDstrcmp(*(const char *const *)s1, *(const char *const *)s2));
+ return (HDstrcmp(*reinterpret_cast<const char *const *>(s1), *reinterpret_cast<const char *const *>(s2)));
}
/*-------------------------------------------------------------------------
@@ -91,7 +92,7 @@ static herr_t
liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR_UNUSED *link_info,
void *op_data)
{
- iter_info *info = (iter_info *)op_data;
+ iter_info *info = static_cast<iter_info *>(op_data);
static int count = 0;
static int count2 = 0;
@@ -133,7 +134,6 @@ liter_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t H5_ATTR
static void
test_iter_group(FileAccPropList &fapl)
{
- int i; /* counting variable */
hsize_t idx; /* Index in the group */
char name[NAMELEN]; /* temporary name buffer */
char * lnames[NDATASETS + 2]; /* Names of the links created */
@@ -159,7 +159,7 @@ test_iter_group(FileAccPropList &fapl)
// Create a scalar file space
DataSpace filespace;
- for (i = 0; i < NDATASETS; i++) {
+ for (int i = 0; i < NDATASETS; i++) {
sprintf(name, "Dataset %d", i);
// Create a dataset in the file
@@ -168,8 +168,7 @@ test_iter_group(FileAccPropList &fapl)
/* Keep a copy of the dataset names */
lnames[i] = HDstrdup(name);
check_values(lnames[i], "HDstrdup returns NULL", __LINE__, __FILE__);
-
- } /* end for */
+ }
/* Create a group and named datatype under root group for testing */
Group grp(file.createGroup(GROUP1, 0));
@@ -181,7 +180,7 @@ test_iter_group(FileAccPropList &fapl)
check_values(lnames[NDATASETS], "HDstrdup returns NULL", __LINE__, __FILE__);
/* Sort the dataset names */
- HDqsort(lnames, (size_t)(NDATASETS + 2), sizeof(char *), iter_strcmp);
+ HDqsort(lnames, NDATASETS + 2, sizeof(char *), iter_strcmp);
/* Iterate through the datasets in the root group in various ways */
@@ -193,10 +192,10 @@ test_iter_group(FileAccPropList &fapl)
// Get the number of object in the root group
hsize_t nobjs = root_group.getNumObjs();
- verify_val(nobjs, (hsize_t)(NDATASETS + 2), "H5Gget_info", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nobjs), NDATASETS + 2, "H5Gget_info", __LINE__, __FILE__);
H5std_string obj_name;
- for (i = 0; i < nobjs; i++) {
+ for (hsize_t i = 0; i < nobjs; i++) {
// H5O_info2_t oinfo; /* Object info */
obj_name = root_group.getObjnameByIdx(i);
@@ -206,7 +205,7 @@ test_iter_group(FileAccPropList &fapl)
// oinfo = root_group.childObjType((hsize_t)i, H5_INDEX_NAME, H5_ITER_INC, ".");
// ret = H5Oget_info_by_idx(root_group, ".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)i, &oinfo,
// H5P_DEFAULT);
- } /* end for */
+ }
// Attempted to iterate with invalid index, should fail
try {
@@ -222,7 +221,7 @@ test_iter_group(FileAccPropList &fapl)
// Attempted to iterate with negative index, should fail
try {
info.command = RET_ZERO;
- idx = (hsize_t)-1;
+ idx = HSIZE_UNDEF;
obj_name = root_group.getObjnameByIdx(idx);
// Should FAIL but didn't, so throw an invalid action exception
@@ -268,7 +267,7 @@ test_iter_group(FileAccPropList &fapl)
} // do nothing, exception expected
/* Free the dataset names */
- for (i = 0; i < (NDATASETS + 2); i++)
+ for (int i = 0; i < NDATASETS + 2; i++)
HDfree(lnames[i]);
// Everything will be closed as they go out of scope
@@ -360,7 +359,7 @@ const H5std_string ATTR_NAME("Units");
const H5std_string FATTR_NAME("F attr");
const H5std_string GATTR_NAME("G attr");
const int DIM1 = 2;
-void
+static void
printelems(const Group &group, const H5std_string &dsname, const H5std_string &atname)
{
try {
diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp
index e8dad5b..8c7f0cd 100644
--- a/c++/test/tlinks.cpp
+++ b/c++/test/tlinks.cpp
@@ -201,7 +201,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Check that its character encoding is the default.
linfo = file.getLinkInfo("/type");
- verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__);
+ verify_val(static_cast<long>(linfo.cset), static_cast<long>(H5T_CSET_ASCII),
+ "Character encoding is not default", __LINE__, __FILE__);
// Create a simple dataspace.
dims[0] = H5L_DIM1;
@@ -214,7 +215,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Check that its character encoding is the default.
linfo = file.getLinkInfo("/dataset");
- verify_val(linfo.cset, H5T_CSET_ASCII, "Character encoding is not default", __LINE__, __FILE__);
+ verify_val(static_cast<long>(linfo.cset), static_cast<long>(H5T_CSET_ASCII),
+ "Character encoding is not default", __LINE__, __FILE__);
// Create a link creation property list with the UTF-8 character encoding.
LinkCreatPropList lcpl;
@@ -226,7 +228,8 @@ test_lcpl(hid_t fapl_id, hbool_t new_format)
// Check that its character encoding is UTF-8.
linfo = file.getLinkInfo(GROUP2NAME);
- verify_val(linfo.cset, H5T_CSET_UTF8, "Character encoding is not UTF-8", __LINE__, __FILE__);
+ verify_val(static_cast<long>(linfo.cset), static_cast<long>(H5T_CSET_UTF8),
+ "Character encoding is not UTF-8", __LINE__, __FILE__);
PASSED();
} // end of try block
@@ -580,12 +583,13 @@ const H5std_string GROUP_NAME("/Data");
const H5std_string DSET1_NAME("/Data/Compressed_Data");
const H5std_string DSET2_NAME("/Data/Float_Data");
const int RANK = 2;
-const int DIM1 = 2;
// Operator function
static int
visit_obj_cb(H5Object &obj, const H5std_string name, const H5O_info2_t *oinfo, void *_op_data)
{
+ (void)obj; // Unused
+
ovisit_ud_t *op_data = static_cast<ovisit_ud_t *>(_op_data);
// Check for correct object information
diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp
index 5892f39..2b694da 100644
--- a/c++/test/tobject.cpp
+++ b/c++/test/tobject.cpp
@@ -87,7 +87,7 @@ test_get_objname()
if (name_len > 4) {
char *grp1_name = new char[5];
name_len = grp1.getObjName(grp1_name, 5);
- verify_val((const char *)grp1_name, "/Top", "Group::getObjName", __LINE__, __FILE__);
+ verify_val(const_cast<const char *>(grp1_name), "/Top", "Group::getObjName", __LINE__, __FILE__);
delete[] grp1_name;
}
@@ -317,8 +317,8 @@ test_get_objname_ontypes()
// Name this datatype
new_int_type.commit(grp, "IntType NATIVE_INT");
ssize_t name_len = new_int_type.getObjName(type_name); // default len
- verify_val(name_len, (ssize_t)HDstrlen("/typetests/IntType NATIVE_INT"), "DataType::getObjName",
- __LINE__, __FILE__);
+ verify_val(name_len, static_cast<ssize_t>(HDstrlen("/typetests/IntType NATIVE_INT")),
+ "DataType::getObjName", __LINE__, __FILE__);
verify_val(type_name, "/typetests/IntType NATIVE_INT", "DataType::getObjName", __LINE__, __FILE__);
// Close everything or they can be closed when objects go out of scope
@@ -366,25 +366,29 @@ test_get_objtype()
// Get and verify object type with
// H5O_type_t childObjType(const H5std_string& objname)
H5O_type_t objtype = file.childObjType(DSET_IN_FILE);
- verify_val(objtype, H5O_TYPE_DATASET, "DataSet::childObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(objtype), static_cast<long>(H5O_TYPE_DATASET), "DataSet::childObjType",
+ __LINE__, __FILE__);
// Get and verify object type with
// H5O_type_t childObjType(const char* objname)
objtype = grp1.childObjType(GROUP1_1.c_str());
- verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(objtype), static_cast<long>(H5O_TYPE_GROUP), "DataSet::childObjType",
+ __LINE__, __FILE__);
// Get and verify object type with
// H5O_type_t childObjType(hsize_t index, H5_index_t index_type,
// H5_iter_order_t order, const char* objname=".")
- objtype = grp1.childObjType((hsize_t)1, H5_INDEX_NAME, H5_ITER_INC);
- verify_val(objtype, H5O_TYPE_NAMED_DATATYPE, "DataSet::childObjType", __LINE__, __FILE__);
+ objtype = grp1.childObjType(1, H5_INDEX_NAME, H5_ITER_INC);
+ verify_val(static_cast<long>(objtype), static_cast<long>(H5O_TYPE_NAMED_DATATYPE),
+ "DataSet::childObjType", __LINE__, __FILE__);
// Get and verify object type with
// H5O_type_t childObjType(hsize_t index,
// H5_index_t index_type=H5_INDEX_NAME,
// H5_iter_order_t order=H5_ITER_INC, const char* objname=".")
- objtype = grp1.childObjType((hsize_t)2);
- verify_val(objtype, H5O_TYPE_GROUP, "DataSet::childObjType", __LINE__, __FILE__);
+ objtype = grp1.childObjType(2);
+ verify_val(static_cast<long>(objtype), static_cast<long>(H5O_TYPE_GROUP), "DataSet::childObjType",
+ __LINE__, __FILE__);
// Everything will be closed as they go out of scope
@@ -455,17 +459,20 @@ test_open_object_header()
// Make sure that each is the right kind of ID
H5I_type_t id_type = IdComponent::getHDFObjType(obj_grp);
- verify_val(id_type, H5I_GROUP, "H5Iget_type for group ID", __LINE__, __FILE__);
+ verify_val(static_cast<long>(id_type), static_cast<long>(H5I_GROUP), "H5Iget_type for group ID",
+ __LINE__, __FILE__);
id_type = IdComponent::getHDFObjType(obj_dtype);
- verify_val(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID", __LINE__, __FILE__);
+ verify_val(static_cast<long>(id_type), static_cast<long>(H5I_DATATYPE), "H5Iget_type for datatype ID",
+ __LINE__, __FILE__);
id_type = IdComponent::getHDFObjType(obj_dset);
- verify_val(id_type, H5I_DATASET, "H5Iget_type for dataset ID", __LINE__, __FILE__);
+ verify_val(static_cast<long>(id_type), static_cast<long>(H5I_DATASET), "H5Iget_type for dataset ID",
+ __LINE__, __FILE__);
/* Do something more complex with each of the IDs to make sure */
Group grp2(obj_grp);
hsize_t num_objs = grp2.getNumObjs();
- verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__);
+ verify_val(static_cast<long>(num_objs), 1, "H5Gget_info", __LINE__, __FILE__);
// There should be one object, the datatype
// Close datatype object opened from the file
@@ -482,7 +489,8 @@ test_open_object_header()
dtype.setId(obj_dtype);
H5T_class_t type_class = dtype.getClass();
- verify_val(type_class, H5T_INTEGER, "H5Tget_class", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_INTEGER), "H5Tget_class", __LINE__,
+ __FILE__);
dtype.close();
// Close datatype object
@@ -493,7 +501,7 @@ test_open_object_header()
// Try doing something with group, the ID should still work
num_objs = grp2.getNumObjs();
- verify_val(num_objs, 1, "H5Gget_info", __LINE__, __FILE__);
+ verify_val(static_cast<long>(num_objs), 1, "H5Gget_info", __LINE__, __FILE__);
// Close the cloned group
grp2.close();
diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp
index 604ccc0..53a4ed3 100644
--- a/c++/test/trefer.cpp
+++ b/c++/test/trefer.cpp
@@ -81,9 +81,9 @@ test_reference_params()
// Allocate write & read buffers
int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
- wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
- rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
- tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ wbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ rbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ tbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
// Create file FILE1
file1 = new H5File(FILE1, H5F_ACC_TRUNC);
@@ -103,7 +103,7 @@ test_reference_params()
unsigned *tu32; // Temporary pointer to uint32 data
int i;
- for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++)
+ for (tu32 = reinterpret_cast<unsigned *>(wbuf), i = 0; i < SPACE1_DIM1; i++)
*tu32++ = i * 3; // from C test
// Write selection to disk
@@ -208,9 +208,9 @@ test_reference_obj()
// Allocate write & read buffers
int temp_size = MAX(sizeof(unsigned), sizeof(hobj_ref_t));
- wbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
- rbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
- tbuf = (hobj_ref_t *)HDmalloc(temp_size * SPACE1_DIM1);
+ wbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ rbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
+ tbuf = static_cast<hobj_ref_t *>(HDmalloc(temp_size * SPACE1_DIM1));
// Create file FILE1
file1 = new H5File(FILE1, H5F_ACC_TRUNC);
@@ -232,7 +232,7 @@ test_reference_obj()
DataSet dataset = group.createDataSet(DSET1_NAME, PredType::NATIVE_UINT, sid1);
unsigned *tu32; // Temporary pointer to uint32 data
- for (tu32 = (unsigned *)wbuf, i = 0; i < SPACE1_DIM1; i++)
+ for (tu32 = reinterpret_cast<unsigned *>(wbuf), i = 0; i < SPACE1_DIM1; i++)
*tu32++ = i * 3; // from C test
// Write selection to disk
@@ -268,22 +268,26 @@ test_reference_obj()
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[0], "/Group1/Dataset1");
H5O_type_t refobj_type = dataset.getRefObjType(&wbuf[0], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(refobj_type), static_cast<long>(H5O_TYPE_DATASET),
+ "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to dataset and test getRefObjType
file1->reference(&wbuf[1], "/Group1/Dataset2");
refobj_type = dataset.getRefObjType(&wbuf[1], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(refobj_type), static_cast<long>(H5O_TYPE_DATASET),
+ "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to group
file1->reference(&wbuf[2], "/Group1");
refobj_type = dataset.getRefObjType(&wbuf[2], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_GROUP, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(refobj_type), static_cast<long>(H5O_TYPE_GROUP),
+ "DataSet::getRefObjType", __LINE__, __FILE__);
// Create reference to named datatype
file1->reference(&wbuf[3], "/Group1/Datatype1");
refobj_type = dataset.getRefObjType(&wbuf[3], H5R_OBJECT);
- verify_val(refobj_type, H5O_TYPE_NAMED_DATATYPE, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(refobj_type), static_cast<long>(H5O_TYPE_NAMED_DATATYPE),
+ "DataSet::getRefObjType", __LINE__, __FILE__);
// Write selection to disk
dataset.write(wbuf, PredType::STD_REF_OBJ);
@@ -309,13 +313,14 @@ test_reference_obj()
// Check information in the referenced dataset
sid1 = dset2.getSpace();
hssize_t n_elements = sid1.getSimpleExtentNpoints();
- verify_val((long)n_elements, 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(n_elements), 4, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
// Read from disk
dset2.read(tbuf, PredType::NATIVE_UINT);
- for (tu32 = (unsigned *)tbuf, i = 0; i < SPACE1_DIM1; i++, tu32++)
- verify_val(*tu32, (uint32_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ for (tu32 = reinterpret_cast<unsigned *>(tbuf), i = 0; i < SPACE1_DIM1; i++, tu32++)
+ verify_val(*tu32, static_cast<uint32_t>(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__,
+ __FILE__);
// Close dereferenced dataset
dset2.close();
@@ -353,7 +358,8 @@ test_reference_obj()
H5T_class_t tclass;
tclass = dtype1.getClass();
- verify_val(tclass, H5T_COMPOUND, "DataType::getClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(tclass), static_cast<long>(H5T_COMPOUND), "DataType::getClass", __LINE__,
+ __FILE__);
int n_members = dtype1.getNmembers();
verify_val(n_members, 3, "CompType::getNmembers", __LINE__, __FILE__);
@@ -468,11 +474,11 @@ test_reference_group()
// Check number of objects in the group dereferenced by constructor
hsize_t nobjs = refgroup.getNumObjs();
- verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nobjs), 3, "H5Group::getNumObjs", __LINE__, __FILE__);
// Check number of objects in the group dereferenced by ::reference
nobjs = group.getNumObjs();
- verify_val(nobjs, (hsize_t)3, "H5Group::getNumObjs", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nobjs), 3, "H5Group::getNumObjs", __LINE__, __FILE__);
// Check getting file name given the group dereferenced via constructor
H5std_string fname = refgroup.getFileName();
@@ -485,13 +491,14 @@ test_reference_group()
// Check object type using Group::getObjinfo()
H5O_info2_t oinfo;
HDmemset(&oinfo, 0, sizeof(oinfo));
- group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)0, oinfo);
- verify_val(oinfo.type, H5O_TYPE_DATASET, "Group::getObjinfo", __LINE__, __FILE__);
+ group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, 0, oinfo);
+ verify_val(static_cast<long>(oinfo.type), static_cast<long>(H5O_TYPE_DATASET), "Group::getObjinfo",
+ __LINE__, __FILE__);
// Check for out of bound query by index
try {
HDmemset(&oinfo, 0, sizeof(oinfo));
- group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, (hsize_t)9, oinfo);
+ group.getObjinfo(".", H5_INDEX_NAME, H5_ITER_INC, 9, oinfo);
// Should FAIL but didn't, so throw an invalid action exception
throw InvalidActionException("Group::getObjinfo", "Out of bound index.");
@@ -502,7 +509,7 @@ test_reference_group()
// Unlink one of the objects in the dereferenced group, and re-check
refgroup.unlink(GROUPNAME2);
nobjs = refgroup.getNumObjs();
- verify_val(nobjs, (hsize_t)2, "H5Group::getNumObjs", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nobjs), 2, "H5Group::getNumObjs", __LINE__, __FILE__);
// Close resources
group.close();
@@ -550,10 +557,10 @@ test_reference_region_1D()
*drbuf; // Buffer for reading numeric data from disk
// Allocate write & read buffers
- wbuf = (hdset_reg_ref_t *)HDcalloc(sizeof(hdset_reg_ref_t), (size_t)SPACE1_DIM1);
- rbuf = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1);
- dwbuf = (uint8_t *)HDmalloc(sizeof(uint8_t) * SPACE3_DIM1);
- drbuf = (uint8_t *)HDcalloc(sizeof(uint8_t), (size_t)SPACE3_DIM1);
+ wbuf = static_cast<hdset_reg_ref_t *>(HDcalloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1));
+ rbuf = static_cast<hdset_reg_ref_t *>(HDmalloc(sizeof(hdset_reg_ref_t) * SPACE1_DIM1));
+ dwbuf = static_cast<uint8_t *>(HDmalloc(sizeof(uint8_t) * SPACE3_DIM1));
+ drbuf = static_cast<uint8_t *>(HDcalloc(sizeof(uint8_t), SPACE3_DIM1));
// Create file FILE1
H5File file1(FILE2, H5F_ACC_TRUNC);
@@ -570,7 +577,7 @@ test_reference_region_1D()
uint8_t *tu8; // Temporary pointer to uint8 data
for (tu8 = dwbuf, i = 0; i < SPACE3_DIM1; i++)
- *tu8++ = i * 3; // from C test
+ *tu8++ = static_cast<uint8_t>(i); // from C test
// Write selection to disk
dset3.write(dwbuf, PredType::STD_U8LE);
@@ -607,7 +614,8 @@ test_reference_region_1D()
// Get and verify object type
H5O_type_t obj_type = dset1.getRefObjType(&wbuf[0], H5R_DATASET_REGION);
- verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(obj_type), static_cast<long>(H5O_TYPE_DATASET), "DataSet::getRefObjType",
+ __LINE__, __FILE__);
/* Select sequence of ten points for second reference */
coord1[0][0] = 16;
@@ -622,7 +630,7 @@ test_reference_region_1D()
coord1[9][0] = 3;
// Selects array elements to be included in the selection for sid3
- sid3.selectElements(H5S_SELECT_SET, (size_t)POINT1_NPOINTS, (const hsize_t *)coord1);
+ sid3.selectElements(H5S_SELECT_SET, POINT1_NPOINTS, reinterpret_cast<const hsize_t *>(coord1));
// Get and verify the number of elements in a dataspace selection
nelms = sid3.getSelectNpoints();
@@ -658,12 +666,14 @@ test_reference_region_1D()
// Get and verify object type
obj_type = dset1.getRefObjType(&rbuf[0], H5R_DATASET_REGION);
- verify_val(obj_type, H5O_TYPE_DATASET, "DataSet::getRefObjType", __LINE__, __FILE__);
+ verify_val(static_cast<long>(obj_type), static_cast<long>(H5O_TYPE_DATASET),
+ "DataSet::getRefObjType", __LINE__, __FILE__);
// Get dataspace of dset3 the verify number of elements
sid1 = dset3.getSpace();
nelms = sid1.getSimpleExtentNpoints();
- verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nelms), 100, "DataSpace::getSimpleExtentNpoints", __LINE__,
+ __FILE__);
} // End of test DataSet::dereference
{ // Test DataSet constructor -by dereference
@@ -674,7 +684,8 @@ test_reference_region_1D()
// Get dataspace of newds then verify number of elements
sid1 = newds.getSpace();
nelms = sid1.getSimpleExtentNpoints();
- verify_val((long)nelms, 100, "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nelms), 100, "DataSpace::getSimpleExtentNpoints", __LINE__,
+ __FILE__);
// Close objects for this mini test
newds.close();
@@ -684,8 +695,9 @@ test_reference_region_1D()
// Read from disk
dset3.read(drbuf, PredType::STD_U8LE);
- for (tu8 = (uint8_t *)drbuf, i = 0; i < SPACE3_DIM1; i++, tu8++)
- verify_val(*tu8, (uint8_t)(i * 3), "DataSpace::getSimpleExtentNpoints", __LINE__, __FILE__);
+ for (tu8 = static_cast<uint8_t *>(drbuf), i = 0; i < SPACE3_DIM1; i++, tu8++)
+ verify_val(*tu8, static_cast<uint8_t>(i), "DataSpace::getSimpleExtentNpoints", __LINE__,
+ __FILE__);
/*
* Test getting the referenced region
@@ -696,56 +708,56 @@ test_reference_region_1D()
// Get and verify number of elements in a dataspace selection
nelms = reg_sp.getSelectNpoints();
- verify_val((long)nelms, 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nelms), 30, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
// Get and verify number of hyperslab blocks
nelms = reg_sp.getSelectHyperNblocks();
- verify_val((long)nelms, 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nelms), 15, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
/* Allocate space for the hyperslab blocks */
- coords = (hsize_t *)HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2);
+ coords = static_cast<hsize_t *>(HDmalloc(nelms * SPACE3_RANK * sizeof(hsize_t) * 2));
// Get the list of hyperslab blocks currently selected
- reg_sp.getSelectHyperBlocklist((hsize_t)0, (hsize_t)nelms, coords);
+ reg_sp.getSelectHyperBlocklist(0, static_cast<hsize_t>(nelms), coords);
// Verify values in the list
- verify_val(coords[0], (hsize_t)2, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[1], (hsize_t)3, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[2], (hsize_t)7, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[3], (hsize_t)8, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[4], (hsize_t)12, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[5], (hsize_t)13, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[6], (hsize_t)17, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[7], (hsize_t)18, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[8], (hsize_t)22, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[9], (hsize_t)23, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[10], (hsize_t)27, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[11], (hsize_t)28, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[12], (hsize_t)32, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[13], (hsize_t)33, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[14], (hsize_t)37, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[15], (hsize_t)38, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[16], (hsize_t)42, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[17], (hsize_t)43, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[18], (hsize_t)47, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[19], (hsize_t)48, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[20], (hsize_t)52, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[21], (hsize_t)53, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[22], (hsize_t)57, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[23], (hsize_t)58, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[24], (hsize_t)62, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[25], (hsize_t)63, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[26], (hsize_t)67, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[27], (hsize_t)68, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[28], (hsize_t)72, "Hyperslab Coordinates", __LINE__, __FILE__);
- verify_val(coords[29], (hsize_t)73, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[0]), 2, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[1]), 3, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[2]), 7, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[3]), 8, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[4]), 12, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[5]), 13, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[6]), 17, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[7]), 18, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[8]), 22, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[9]), 23, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[10]), 27, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[11]), 28, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[12]), 32, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[13]), 33, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[14]), 37, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[15]), 38, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[16]), 42, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[17]), 43, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[18]), 47, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[19]), 48, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[20]), 52, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[21]), 53, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[22]), 57, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[23]), 58, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[24]), 62, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[25]), 63, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[26]), 67, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[27]), 68, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[28]), 72, "Hyperslab Coordinates", __LINE__, __FILE__);
+ verify_val(static_cast<long>(coords[29]), 73, "Hyperslab Coordinates", __LINE__, __FILE__);
HDfree(coords);
// Check boundaries
reg_sp.getSelectBounds(low, high);
- verify_val(low[0], (hsize_t)2, "DataSpace::getSelectBounds", __LINE__, __FILE__);
- verify_val(high[0], (hsize_t)73, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(static_cast<long>(low[0]), 2, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(static_cast<long>(high[0]), 73, "DataSpace::getSelectBounds", __LINE__, __FILE__);
/* Close region space */
reg_sp.close();
@@ -759,13 +771,13 @@ test_reference_region_1D()
// Get and verify number of element points in the current selection
hssize_t nelmspts = elm_sp.getSelectElemNpoints();
- verify_val((long)nelmspts, 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
+ verify_val(static_cast<long>(nelmspts), 10, "DataSpace::getSelectNpoints", __LINE__, __FILE__);
/* Allocate space for the hyperslab blocks */
- coords = (hsize_t *)HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t));
+ coords = static_cast<hsize_t *>(HDmalloc(nelmspts * SPACE3_RANK * sizeof(hsize_t)));
// Get the list of element points currently selected
- elm_sp.getSelectElemPointlist((hsize_t)0, (hsize_t)nelmspts, coords);
+ elm_sp.getSelectElemPointlist(0, static_cast<hsize_t>(nelmspts), coords);
// Verify points
verify_val(coords[0], coord1[0][0], "Element Coordinates", __LINE__, __FILE__);
@@ -783,8 +795,8 @@ test_reference_region_1D()
// Check boundaries
elm_sp.getSelectBounds(low, high);
- verify_val(low[0], (hsize_t)3, "DataSpace::getSelectBounds", __LINE__, __FILE__);
- verify_val(high[0], (hsize_t)97, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(static_cast<long>(low[0]), 3, "DataSpace::getSelectBounds", __LINE__, __FILE__);
+ verify_val(static_cast<long>(high[0]), 97, "DataSpace::getSelectBounds", __LINE__, __FILE__);
// Close element space
elm_sp.close();
diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp
index 7d0337d..1cedef6 100644
--- a/c++/test/ttypes.cpp
+++ b/c++/test/ttypes.cpp
@@ -110,8 +110,8 @@ test_classes()
// PredType::NATIVE_DOUBLE should be in H5T_FLOAT class
tcls = PredType::NATIVE_DOUBLE.getClass();
if (H5T_FLOAT != tcls) {
- verify_val(tcls, H5T_FLOAT, "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__,
- __FILE__);
+ verify_val(static_cast<long>(tcls), static_cast<long>(H5T_FLOAT),
+ "test_class: invalid type class for NATIVE_DOUBLE -", __LINE__, __FILE__);
}
PASSED();
} // end of try block
@@ -727,7 +727,7 @@ test_named()
Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space);
for (hsize_t i = 0; i < ds_size[0]; i++) {
for (hsize_t j = 0; j < ds_size[1]; j++) {
- attr_data[i][j] = (unsigned)(i * ds_size[1] + j);
+ attr_data[i][j] = static_cast<unsigned>(i * ds_size[1] + j);
}
}
attr1.write(PredType::NATIVE_UINT, attr_data);
@@ -989,7 +989,8 @@ test_encode_decode()
// Create an IntType instance from the decoded pointer and verify it
IntType * decoded_int_ptr(static_cast<IntType *>(inttyp.decode()));
H5T_sign_t int_sign = decoded_int_ptr->getSign();
- verify_val(int_sign, H5T_SGN_NONE, "DataType::decode", __LINE__, __FILE__);
+ verify_val(static_cast<long>(int_sign), static_cast<long>(H5T_SGN_NONE), "DataType::decode", __LINE__,
+ __FILE__);
verify_val(inttyp == *decoded_int_ptr, true, "DataType::decode", __LINE__, __FILE__);
delete decoded_int_ptr;
diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp
index 9c0f78a..c91b566 100644
--- a/c++/test/tvlstr.cpp
+++ b/c++/test/tvlstr.cpp
@@ -183,7 +183,7 @@ test_vlstring_dataset()
// Test scalar type dataset with 1 value.
dset1 = root.createDataSet("test_scalar_small", vlst, ds_space);
- dynstring_ds_write = (char *)HDcalloc(2, sizeof(char));
+ dynstring_ds_write = static_cast<char *>(HDcalloc(2, sizeof(char)));
HDmemset(dynstring_ds_write, 'A', 1);
// Write data to the dataset, then read it back.
@@ -285,7 +285,7 @@ test_vlstring_array_dataset()
// Create and write another dataset.
DataSet dataset2(file1->createDataSet("Dataset2", vlst, scalar_space));
- char * wdata2 = (char *)HDcalloc(65534, sizeof(char));
+ char * wdata2 = static_cast<char *>(HDcalloc(65534, sizeof(char)));
HDmemset(wdata2, 'A', 65533);
dataset2.write(&wdata2, vlst);
@@ -360,7 +360,7 @@ test_vlstrings_special()
hsize_t ii; // counting variable
for (ii = 0; ii < SPACE1_DIM1; ii++)
if (rdata[ii] != NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast<int>(ii), rdata[ii]);
// Write dataset to disk, then read it back.
dataset.write(wdata, vlst);
@@ -372,18 +372,19 @@ test_vlstrings_special()
size_t rlen = HDstrlen(rdata[ii]);
if (wlen != rlen) {
TestErrPrintf("VL data lengths don't match!, strlen(wdata[%d])=%u, strlen(rdata[%d])=%u\n",
- (int)ii, (unsigned)wlen, (int)ii, (unsigned)rlen);
+ static_cast<int>(ii), static_cast<unsigned>(wlen), static_cast<int>(ii),
+ static_cast<unsigned>(rlen));
continue;
- } // end if
+ }
if (HDstrcmp(wdata[ii], rdata[ii]) != 0) {
- TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)ii, wdata[ii],
- (int)ii, rdata[ii]);
+ TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
+ static_cast<int>(ii), wdata[ii], static_cast<int>(ii), rdata[ii]);
continue;
- } // end if
- } // end for
+ }
+ }
// Reclaim the read VL data.
- DataSet::vlenReclaim((void *)rdata, vlst, sid1);
+ DataSet::vlenReclaim(static_cast<void *>(rdata), vlst, sid1);
// Close Dataset.
dataset.close();
@@ -408,7 +409,7 @@ test_vlstrings_special()
// Check data read in.
for (ii = 0; ii < SPACE1_DIM1; ii++)
if (rdata[ii] != NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast<int>(ii), rdata[ii]);
// Try to write nil strings to disk.
dataset.write(wdata2, vlst);
@@ -419,7 +420,7 @@ test_vlstrings_special()
// Check data read in.
for (ii = 0; ii < SPACE1_DIM1; ii++)
if (rdata[ii] != NULL)
- TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", (int)ii, rdata[ii]);
+ TestErrPrintf("VL doesn't match!, rdata[%d]=%p\n", static_cast<int>(ii), rdata[ii]);
// Close objects and file.
dataset.close();
@@ -467,22 +468,26 @@ test_vlstring_type()
// Change padding and verify it.
vlst.setStrpad(H5T_STR_NULLPAD);
H5T_str_t pad = vlst.getStrpad();
- verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__);
+ verify_val(static_cast<long>(pad), static_cast<long>(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__,
+ __FILE__);
// Convert to variable-length string.
vlst.setSize(H5T_VARIABLE);
// Check if datatype is VL string.
H5T_class_t type_class = vlst.getClass();
- verify_val(type_class, H5T_STRING, "DataType::getClass", __LINE__, __FILE__);
+ verify_val(static_cast<long>(type_class), static_cast<long>(H5T_STRING), "DataType::getClass",
+ __LINE__, __FILE__);
bool is_variable_str = vlst.isVariableStr();
verify_val(is_variable_str, true, "DataType::isVariableStr", __LINE__, __FILE__);
// Check default character set and padding.
H5T_cset_t cset = vlst.getCset();
- verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__);
+ verify_val(static_cast<long>(cset), static_cast<long>(H5T_CSET_ASCII), "StrType::getCset", __LINE__,
+ __FILE__);
pad = vlst.getStrpad();
- verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__);
+ verify_val(static_cast<long>(pad), static_cast<long>(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__,
+ __FILE__);
// Commit variable-length string datatype to storage.
vlst.commit(*file1, VLSTR_TYPE);
@@ -510,9 +515,11 @@ test_vlstring_type()
// Verify character set and padding
cset = vlst2.getCset();
- verify_val(cset, H5T_CSET_ASCII, "StrType::getCset", __LINE__, __FILE__);
+ verify_val(static_cast<long>(cset), static_cast<long>(H5T_CSET_ASCII), "StrType::getCset", __LINE__,
+ __FILE__);
pad = vlst2.getStrpad();
- verify_val(pad, H5T_STR_NULLPAD, "StrType::getStrpad", __LINE__, __FILE__);
+ verify_val(static_cast<long>(pad), static_cast<long>(H5T_STR_NULLPAD), "StrType::getStrpad", __LINE__,
+ __FILE__);
// Close datatype and file
vlst2.close();
@@ -578,18 +585,19 @@ test_compact_vlstring()
for (i = 0; i < SPACE1_DIM1; i++) {
if (HDstrlen(wdata[i]) != strlen(rdata[i])) {
TestErrPrintf("VL data length don't match!, strlen(wdata[%d])=%d, strlen(rdata[%d])=%d\n",
- (int)i, (int)strlen(wdata[i]), (int)i, (int)strlen(rdata[i]));
+ static_cast<int>(i), static_cast<int>(HDstrlen(wdata[i])), static_cast<int>(i),
+ static_cast<int>(HDstrlen(rdata[i])));
continue;
} // end if
if (HDstrcmp(wdata[i], rdata[i]) != 0) {
- TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n", (int)i, wdata[i],
- (int)i, rdata[i]);
+ TestErrPrintf("VL data values don't match!, wdata[%d]=%s, rdata[%d]=%s\n",
+ static_cast<int>(i), wdata[i], static_cast<int>(i), rdata[i]);
continue;
} // end if
} // end for
// Reclaim the read VL data
- DataSet::vlenReclaim((void *)rdata, vlst, sid1);
+ DataSet::vlenReclaim(static_cast<void *>(rdata), vlst, sid1);
// Close objects and file
dataset.close();
@@ -670,7 +678,7 @@ test_vlstring_attribute()
// Test creating a "large" sized string attribute
gr_attr = root.createAttribute("test_scalar_large", vlst, att_space);
- string_att_write = (char *)HDcalloc(8192, sizeof(char));
+ string_att_write = static_cast<char *>(HDcalloc(8192, sizeof(char)));
HDmemset(string_att_write, 'A', 8191);
// Write data to the attribute, then read it back.