From 20bfdeb2c16ded5bfefed3a505a73dbaca6e7e60 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 8 Mar 2016 22:30:02 -0500 Subject: [svn-r29361] Purpose: Correction Description: Replaced static_cast with reinterpret_cast for "void *". Removed some commented-out old code. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test) --- c++/src/H5Location.cpp | 4 ++-- c++/test/dsets.cpp | 28 ++++++++++++++-------------- c++/test/tarray.cpp | 2 -- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 337aa6f..e2b68ae 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -50,7 +50,7 @@ extern "C" herr_t userAttrOpWrpr(hid_t loc_id, const char *attr_name, #ifdef NO_STATIC_CAST UserData4Aiterate* myData = (UserData4Aiterate *) op_data; #else - UserData4Aiterate* myData = static_cast (op_data); + UserData4Aiterate* myData = reinterpret_cast (op_data); #endif myData->op( *myData->location, s_attr_name, myData->opData ); return 0; @@ -232,7 +232,7 @@ int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_ // call the C library routine H5Aiterate2 to iterate the attributes hsize_t idx = _idx ? (hsize_t)*_idx : 0; int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, - userAttrOpWrpr, static_cast(userData)); + userAttrOpWrpr, reinterpret_cast(userData)); // release memory delete userData; diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 1837d17..60e875c 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -246,10 +246,10 @@ test_simple_io( H5File& file) DataSet dataset (file.createDataSet (DSET_SIMPLE_IO_NAME, PredType::NATIVE_INT, space)); // Write the data to the dataset - dataset.write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write(reinterpret_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Read the dataset back - dataset.read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < 100; i++) @@ -395,10 +395,10 @@ test_tconv( H5File& file) DataSet dataset (file.createDataSet (DSET_TCONV_NAME, PredType::STD_I32LE, space)); // Write the data to the dataset - dataset.write (static_cast(out), PredType::STD_I32LE); + dataset.write (reinterpret_cast(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (static_cast(in), PredType::STD_I32BE); + dataset.read (reinterpret_cast(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { @@ -539,7 +539,7 @@ test_compression(H5File& file) */ SUBTEST("Compression (uninitialized read)"); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); for (i=0; iwrite (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (reinterpret_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); PASSED(); @@ -580,7 +580,7 @@ test_compression(H5File& file) SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) @@ -609,10 +609,10 @@ test_compression(H5File& file) points[i][j] = rand (); } } - dataset->write (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (reinterpret_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Read the dataset back and check it - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) @@ -637,7 +637,7 @@ test_compression(H5File& file) delete dataset; dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) @@ -667,8 +667,8 @@ test_compression(H5File& file) } } space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (static_cast(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, space1, space1, xfer); + dataset->write (reinterpret_cast(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, space1, space1, xfer); // Check that the values read are the same as the values written for (i=0; iwrite (static_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (static_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (reinterpret_cast(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (reinterpret_cast(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Check that the values read are the same as the values written for (i = 0; i < size[0]; i++) diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index e73cfd0..a6cbae4 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -94,9 +94,7 @@ static void test_array_compound_array() for(idxk = 0; idxk < ARRAY1_DIM1; idxk++) { float temp = idxi * 10.0 + idxj * 2.5 + idxk; - //wdata[idxi][idxj].f[idxk]=(float)(idxi * 10.0F + idxj * 2.5F + idxk); wdata[idxi][idxj].f[idxk] = temp; - //wdata[idxi][idxj].f[idxk] = static_cast(temp); } } // end for -- cgit v0.12