summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2015-04-06 23:47:09 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2015-04-06 23:47:09 (GMT)
commit343a52747c234f41da2e007a696786a51f74ad69 (patch)
treee5e0d34cc44afb19c5d13c89a9b19037f4284a38
parent5a810576d55f21ee8a872b904026647358113836 (diff)
downloadhdf5-343a52747c234f41da2e007a696786a51f74ad69.zip
hdf5-343a52747c234f41da2e007a696786a51f74ad69.tar.gz
hdf5-343a52747c234f41da2e007a696786a51f74ad69.tar.bz2
[svn-r26743] Purpose: Fix daily test failure
Description: - In DataType::DataType(const PredType& pred_type), using DataType::copy will invoke DataType::close() unnecessarily, which will produce undefined behavior. Changed to call H5Tcopy directly, code reuse is not useful in this case. - Also, fixed CommonFG::childObjVersion to return expected value outside of an if/else block. Merged from trunk r26737. Platforms tested: Linux/ppc64 (ostrich) Linux/64 (platypus) Linux/32 2.6 (jam)
-rw-r--r--c++/src/H5CommonFG.cpp8
-rw-r--r--c++/src/H5DataType.cpp21
-rw-r--r--c++/src/H5Object.cpp2
3 files changed, 18 insertions, 13 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index 1547a5b..42a8ffd 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -14,7 +14,6 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string>
-#include <iostream>
#include "H5Include.h"
#include "H5Exception.h"
@@ -49,7 +48,6 @@
#ifndef H5_NO_NAMESPACE
namespace H5 {
-using namespace std;
#endif
//--------------------------------------------------------------------------
@@ -1130,6 +1128,7 @@ H5O_type_t CommonFG::childObjType(hsize_t index, H5_index_t index_type, H5_iter_
unsigned CommonFG::childObjVersion(const char* objname) const
{
H5O_info_t objinfo;
+ unsigned version = -1;
// Use C API to get information of the object
herr_t ret_value = H5Oget_info_by_name(getLocId(), objname, &objinfo, H5P_DEFAULT);
@@ -1140,12 +1139,11 @@ unsigned CommonFG::childObjVersion(const char* objname) const
// Return a valid version or throw an exception for invalid value
else
{
- unsigned version = objinfo.hdr.version;
+ version = objinfo.hdr.version;
if (version != H5O_VERSION_1 && version != H5O_VERSION_2)
throwException("childObjVersion", "Invalid version for object");
- else
- return(version);
}
+ return(version);
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index aed0dd1..714f55f 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -123,7 +123,7 @@ DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type)
// Jul, 2008
// Added for application convenience.
//--------------------------------------------------------------------------
-DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object(), id(H5I_INVALID_HID)
+DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type) : H5Object()
{
id = H5Location::p_dereference(attr.getId(), ref, ref_type, "constructor - by dereference");
}
@@ -141,18 +141,23 @@ DataType::DataType(const DataType& original) : H5Object()
//--------------------------------------------------------------------------
// Function: DataType overloaded constructor
-///\brief Creates a integer type using a predefined type
-///\param pred_type - IN: Predefined datatype
+///\brief Creates a DataType instance using a predefined type
+///\param pred_type - IN: Predefined type instance
///\exception H5::DataTypeIException
-// Programmer Binh-Minh Ribler - 2000
+// Programmer Binh-Minh Ribler - 2015
// Description
-// This is so that when a predefined type is passed in, a
-// copy of it is made, not just a duplicate of the HDF5 id.
+// Copying the type so that when a predefined type is passed in,
+// a copy of it is made, not just a duplicate of the HDF5 id.
+// Note: calling DataType::copy will invoke DataType::close()
+// unnecessarily and will produce undefined behavior.
+// -BMR, Apr 2015
//--------------------------------------------------------------------------
DataType::DataType(const PredType& pred_type) : H5Object()
{
- // use DataType::copy to make a copy of this predefined type
- copy(pred_type);
+ // call C routine to copy the datatype
+ id = H5Tcopy( pred_type.getId() );
+ if( id < 0 )
+ throw DataTypeIException("DataType constructor", "H5Tcopy failed");
}
//--------------------------------------------------------------------------
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index df3f565..56e88e0 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -14,6 +14,7 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <string>
+#include <iostream>
#include "H5Include.h"
#include "H5Exception.h"
@@ -35,6 +36,7 @@
#ifndef H5_NO_NAMESPACE
namespace H5 {
+using namespace std;
#endif
#ifndef DOXYGEN_SHOULD_SKIP_THIS