From 10f1e6acf8916a429f2cc925f49518cfc0015b6c Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 30 Sep 2014 13:20:36 -0500 Subject: [svn-r25640] Purpose: Fixed HDFFV-4259 Description: - Used H5I_INVALID_HID instead of 0 to initialized member "id" in classes that represent HDF5 objects. For PropList, H5P_DEFAULT has to be used instead of H5I_INVALID_HID. - Added try/catch block to some dynamically allocating memory code and re-throw the bad_alloc exception with a message informing the location of the failure. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu) --- c++/src/H5ArrayType.cpp | 55 ++++++++++++++++++++++++++++++----------------- c++/src/H5Attribute.cpp | 12 +++++------ c++/src/H5CommonFG.cpp | 3 +++ c++/src/H5DataSet.cpp | 8 +++---- c++/src/H5DataSpace.cpp | 2 +- c++/src/H5DataSpace.h | 12 +++++------ c++/src/H5DataType.cpp | 8 +++---- c++/src/H5File.cpp | 8 +++---- c++/src/H5Group.cpp | 8 +++---- c++/src/H5IdComponent.cpp | 4 ++-- c++/src/H5Location.cpp | 3 +++ c++/src/H5PropList.cpp | 6 +++--- 12 files changed, 75 insertions(+), 54 deletions(-) diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 852658b..5a3f860 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -54,15 +54,18 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) rank = H5Tget_array_ndims(existing_id); if (rank < 0) { - throw DataTypeIException("ArrayType overloaded constructor", "H5Tget_array_ndims failed"); + throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_ndims failed"); } - // Get the dimensions of the existing array and store it in this array - dimensions = new hsize_t[rank]; - //hsize_t rdims2[H5S_MAX_RANK]; - int ret_value = H5Tget_array_dims2(id, dimensions); - if (ret_value < 0) - throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); + // Get the dimensions of the existing array and store it in this array + try { + dimensions = new hsize_t[rank]; + } catch (const std::bad_alloc&) { + throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); + } + int ret_value = H5Tget_array_dims2(id, dimensions); + if (ret_value < 0) + throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_dims2 failed"); } //-------------------------------------------------------------------------- @@ -72,10 +75,14 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) //-------------------------------------------------------------------------- ArrayType::ArrayType( const ArrayType& original ) : DataType( original ) { - rank = original.rank; - dimensions = new hsize_t[rank]; - for (int i = 0; i < rank; i++) - dimensions[i] = original.dimensions[i]; + rank = original.rank; + try { + dimensions = new hsize_t[rank]; + } catch (const std::bad_alloc&) { + throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); + } + for (int i = 0; i < rank; i++) + dimensions[i] = original.dimensions[i]; } //-------------------------------------------------------------------------- @@ -90,14 +97,18 @@ ArrayType::ArrayType( const ArrayType& original ) : DataType( original ) //-------------------------------------------------------------------------- ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() { - hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); - if (new_type_id < 0) - throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed"); - id = new_type_id; - rank = ndims; - dimensions = new hsize_t[rank]; - for (int i = 0; i < rank; i++) - dimensions[i] = dims[i]; + hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); + if (new_type_id < 0) + throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed"); + id = new_type_id; + rank = ndims; + try { + dimensions = new hsize_t[rank]; + } catch (const std::bad_alloc&) { + throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); + } + for (int i = 0; i < rank; i++) + dimensions[i] = dims[i]; } //-------------------------------------------------------------------------- @@ -140,7 +151,11 @@ int ArrayType::getArrayDims(hsize_t* dims) throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); // store the array's info in memory rank = ndims; - dimensions = new hsize_t[rank]; + try { + dimensions = new hsize_t[rank]; + } catch (const std::bad_alloc&) { + throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); + } for (int i = 0; i < rank; i++) dimensions[i] = dims[i]; } diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index bdd0ac0..a9e928d 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -50,7 +50,7 @@ class H5_DLLCPP H5Object; // forward declaration for UserData4Aiterate ///\brief Default constructor: Creates a stub attribute // Programmer Binh-Minh Ribler - May, 2004 //-------------------------------------------------------------------------- -Attribute::Attribute() : AbstractDs(), IdComponent(), id(0) {} +Attribute::Attribute() : AbstractDs(), IdComponent(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- // Function: Attribute copy constructor @@ -162,13 +162,13 @@ void Attribute::read( const DataType& mem_type, void *buf ) const // Mar 2008 // Corrected a misunderstanding that H5Aread would allocate // space for the buffer. Obtained the attribute size and -// allocated memory properly. - BMR +// allocated memory properly. -BMR // Apr 2009 -// Used getInMemDataSize to get attribute data size. - BMR +// Used getInMemDataSize to get attribute data size. -BMR // Jul 2009 // Divided into specific private functions for fixed- and // variable-len string data: p_read_fixed_len and -// p_read_variable_len. This should improve readability. +// p_read_variable_len. This should improve readability. -BMR //-------------------------------------------------------------------------- void Attribute::read(const DataType& mem_type, H5std_string& strg) const { @@ -586,7 +586,7 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c // Modification // Jul 2009 // Separated the variable length case from the original -// Attribute::read +// Attribute::read. -BMR //-------------------------------------------------------------------------- void Attribute::p_read_variable_len(const DataType& mem_type, H5std_string& strg) const { @@ -650,7 +650,7 @@ void Attribute::close() throw AttributeIException("Attribute::close", "H5Aclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index d296db4..8ee88d6 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -33,6 +33,9 @@ #include "H5Alltypes.h" #include "H5private.h" // for HDstrcpy +#include +using namespace std; + // There are a few comments that are common to most of the functions // defined in this file so they are listed here. // - getLocId is called by all functions, that call a C API, to get diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index c34769e..6728264 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -52,7 +52,7 @@ namespace H5 { ///\brief Default constructor: creates a stub DataSet. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataSet::DataSet() : AbstractDs(), H5Object(), id(0) {} +DataSet::DataSet() : AbstractDs(), H5Object(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- // Function: DataSet overloaded constructor @@ -95,7 +95,7 @@ DataSet::DataSet(const DataSet& original) : AbstractDs(original), H5Object(origi // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(0) +DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereferenced"); } @@ -114,7 +114,7 @@ DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type, co // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(0) +DataSet::DataSet(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : AbstractDs(), H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -788,7 +788,7 @@ void DataSet::close() throw DataSetIException("DataSet::close", "H5Dclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 6ad8c8d..20b4e5e 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -630,7 +630,7 @@ void DataSpace::close() throw DataSpaceIException("DataSpace::close", "H5Sclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h index 9efecdf..b007fd0 100644 --- a/c++/src/H5DataSpace.h +++ b/c++/src/H5DataSpace.h @@ -33,6 +33,12 @@ class H5_DLLCPP DataSpace : public IdComponent { // Creates a simple dataspace DataSpace(int rank, const hsize_t * dims, const hsize_t * maxdims = NULL); + // Creates a DataSpace object using an existing dataspace id. + DataSpace(const hid_t space_id); + + // Copy constructor: makes a copy of the original DataSpace object. + DataSpace(const DataSpace& original); + // Assignment operator DataSpace& operator=( const DataSpace& rhs ); @@ -109,12 +115,6 @@ class H5_DLLCPP DataSpace : public IdComponent { ///\brief Returns this class name. virtual H5std_string fromClass () const { return("DataSpace"); } - // Creates a DataSpace object using an existing dataspace id. - DataSpace(const hid_t space_id); - - // Copy constructor: makes a copy of the original DataSpace object. - DataSpace(const DataSpace& original); - // Gets the dataspace id. virtual hid_t getId() const; diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index afc5678..a435b4e 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -53,7 +53,7 @@ namespace H5 { ///\brief Default constructor: Creates a stub datatype // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -DataType::DataType() : H5Object(), id(0) {} +DataType::DataType() : H5Object(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- // Function: DataType overloaded constructor @@ -105,7 +105,7 @@ DataType::DataType( const H5T_class_t type_class, size_t size ) : H5Object() // Jul, 2008 // Added for application convenience. //-------------------------------------------------------------------------- -DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0) +DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -124,7 +124,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, const PropList& plist) : H5Object(), id(0) +DataType::DataType(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -710,7 +710,7 @@ void DataType::close() throw DataTypeIException(inMemFunc("close"), "H5Tclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index ff00e3b..45e08b2 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -50,7 +50,7 @@ namespace H5 { ///\brief Default constructor: creates a stub H5File object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5File::H5File() : H5Location(), id(0) {} +H5File::H5File() : H5Location(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- // Function: H5File overloaded constructor @@ -86,7 +86,7 @@ H5File::H5File() : H5Location(), id(0) {} // to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(0) +H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(H5I_INVALID_HID) { try { p_get_file(name, flags, create_plist, access_plist); @@ -111,7 +111,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c // to catch then re-throw it. -BMR 2013/03/21 // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(0) +H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPropList& create_plist, const FileAccPropList& access_plist ) : H5Location(), id(H5I_INVALID_HID) { try { p_get_file(name.c_str(), flags, create_plist, access_plist); @@ -604,7 +604,7 @@ void H5File::close() throw FileIException("H5File::close", "H5Fclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index 7679315..cad5e29 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -51,7 +51,7 @@ namespace H5 { ///\brief Default constructor: creates a stub Group. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -Group::Group() : H5Object(), id(0) {} +Group::Group() : H5Object(), id(H5I_INVALID_HID) {} //-------------------------------------------------------------------------- // Function: Group copy constructor @@ -100,7 +100,7 @@ Group::Group(const hid_t existing_id) : H5Object() /// is a datatype that has been named by DataType::commit. // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0) +Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -115,7 +115,7 @@ Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type, const ///\exception H5::ReferenceException // Programmer Binh-Minh Ribler - Oct, 2006 //-------------------------------------------------------------------------- -Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(0) +Group::Group(const Attribute& attr, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object(), id(H5I_INVALID_HID) { id = H5Location::p_dereference(attr.getId(), ref, ref_type, plist, "constructor - by dereference"); } @@ -181,7 +181,7 @@ void Group::close() throw GroupIException("Group::close", "H5Gclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 99a8dc4..64297ee 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -145,7 +145,7 @@ int IdComponent::getCounter() const //-------------------------------------------------------------------------- H5I_type_t IdComponent::getHDFObjType(const hid_t obj_id) { - if (obj_id == 0) + if (obj_id <= 0) return H5I_BADID; // invalid H5I_type_t id_type = H5Iget_type(obj_id); if (id_type <= H5I_BADID || id_type >= H5I_NTYPES) @@ -339,7 +339,7 @@ H5std_string IdComponent::p_get_file_name() const //-------------------------------------------------------------------------- bool IdComponent::p_valid_id(const hid_t obj_id) { - if (obj_id == 0) + if (obj_id <= 0) return false; H5I_type_t id_type = H5Iget_type(obj_id); diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 9d3d7bf..89f10b5 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -33,6 +33,9 @@ #include "H5DataSet.h" #include "H5Attribute.h" #include "H5private.h" // for HDmemset +#include +using namespace std; + #ifndef H5_NO_NAMESPACE namespace H5 { diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 0b740d8..56743f7 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -46,7 +46,7 @@ const PropList PropList::DEFAULT; ///\brief Default constructor: creates a stub property list object. // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -PropList::PropList() : IdComponent(), id(0) {} +PropList::PropList() : IdComponent(), id(H5P_DEFAULT) {} //-------------------------------------------------------------------------- // Function: PropList copy constructor @@ -74,7 +74,7 @@ PropList::PropList(const PropList& original) : IdComponent(original) //-------------------------------------------------------------------------- PropList::PropList( const hid_t plist_id ) : IdComponent() { - if (plist_id == 0) + if (plist_id <= 0) id = H5P_DEFAULT; H5I_type_t id_type = H5Iget_type(plist_id); @@ -277,7 +277,7 @@ void PropList::close() throw PropListIException(inMemFunc("close"), "H5Pclose failed"); } // reset the id - id = 0; + id = H5I_INVALID_HID; } } -- cgit v0.12 From 22d0d32716a588063970a7e412d69a2937118034 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 30 Sep 2014 23:05:57 -0500 Subject: [svn-r25644] Purpose: Fixed HDFFV-8928 Description: Followed hints on the JIRA issue to remove several potential memory leaks. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu) --- c++/src/H5CommonFG.cpp | 14 ++++++++++++++ c++/src/H5EnumType.cpp | 1 + c++/src/H5Exception.cpp | 6 ++++++ c++/src/H5IdComponent.cpp | 1 + c++/src/H5Location.cpp | 1 + c++/src/H5PropList.cpp | 1 + c++/test/tfile.cpp | 2 +- 7 files changed, 25 insertions(+), 1 deletion(-) diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp index 8ee88d6..3aa0386 100644 --- a/c++/src/H5CommonFG.cpp +++ b/c++/src/H5CommonFG.cpp @@ -443,7 +443,10 @@ H5std_string CommonFG::getLinkval( const char* name, size_t size ) const ret_value = H5Lget_val(getLocId(), name, value_C, val_size, H5P_DEFAULT); if( ret_value < 0 ) + { + delete []value_C; throwException("getLinkval", "H5Lget_val failed"); + } value = H5std_string(value_C); delete []value_C; @@ -916,6 +919,12 @@ H5std_string CommonFG::getObjnameByIdx(hsize_t idx) const name_len = H5Lget_name_by_idx(getLocId(), ".", H5_INDEX_NAME, H5_ITER_INC, idx, name_C, name_len+1, H5P_DEFAULT); + if (name_len < 0) + { + delete []name_C; + throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + } + // clean up and return the string H5std_string name = H5std_string(name_C); delete []name_C; @@ -960,10 +969,15 @@ ssize_t CommonFG::getObjnameByIdx(hsize_t idx, H5std_string& name, size_t size) char* name_C = new char[size+1]; // temporary C-string for object name HDmemset(name_C, 0, size+1); // clear buffer + // call overloaded function to get the name ssize_t name_len = getObjnameByIdx(idx, name_C, size+1); if(name_len < 0) + { + delete []name_C; throwException("getObjnameByIdx", "H5Lget_name_by_idx failed"); + } + // clean up and return the string name = H5std_string(name_C); delete []name_C; return (name_len); diff --git a/c++/src/H5EnumType.cpp b/c++/src/H5EnumType.cpp index 04bb9e0..a91c053 100644 --- a/c++/src/H5EnumType.cpp +++ b/c++/src/H5EnumType.cpp @@ -159,6 +159,7 @@ H5std_string EnumType::nameOf( void *value, size_t size ) const // If H5Tenum_nameof returns a negative value, raise an exception, if( ret_value < 0 ) { + delete []name_C; throw DataTypeIException("EnumType::nameOf", "H5Tenum_nameof failed"); } // otherwise, create the string to hold the datatype name and return it diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 5e7ccd4..f153c92 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -80,8 +80,11 @@ H5std_string Exception::getMajorString( hid_t err_major ) const // Check for failure again if( mesg_size < 0 ) + { + delete []mesg_C; throw IdComponentException("Exception::getMajorString", "H5Eget_msg failed"); + } // Convert the C error description and return H5std_string major_str(mesg_C); @@ -116,8 +119,11 @@ H5std_string Exception::getMinorString( hid_t err_minor ) const // Check for failure again if( mesg_size < 0 ) + { + delete []mesg_C; throw IdComponentException("Exception::getMinorString", "H5Eget_msg failed"); + } // Convert the C error description and return H5std_string minor_str(mesg_C); diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 64297ee..4a9dcac 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -317,6 +317,7 @@ H5std_string IdComponent::p_get_file_name() const // Check for failure again if( name_size < 0 ) { + delete []name_C; throw IdComponentException("", "H5Fget_name failed"); } diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index 89f10b5..cd733c4 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -554,6 +554,7 @@ H5std_string H5Location::getComment(const char* name, size_t buf_size) const ssize_t comment_len = getComment(name, tmp_len+1, comment_C); if (comment_len < 0) { + delete []comment_C; throw LocationException("H5Location::getComment", "H5Oget_comment_by_name failed"); } diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 56743f7..5afe80f 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -402,6 +402,7 @@ H5std_string PropList::getProperty(const char* name) const // Throw exception if H5Pget returns failure if (ret_value < 0) { + delete []prop_strg_C; throw PropListIException(inMemFunc("getProperty"), "H5Pget failed"); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index ecfa8d0..ad5e6fc 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -598,7 +598,7 @@ static void test_file_attribute() } // end of try block catch (Exception E) { - issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); + issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_file_attribute() -- cgit v0.12 From 1df7b415ab51697c3e5af31fcfc799c07c0b82b6 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Tue, 30 Sep 2014 23:31:37 -0500 Subject: [svn-r25645] Description: Removed the try/block with new/bad_alloc that were unintentionally committed previously. Platforms tested: Linux/ppc64 (ostrich) Linux/32 2.6 (jam) SunOS 5.11 (emu) --- c++/src/H5ArrayType.cpp | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 5a3f860..8807dca 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -57,12 +57,10 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_ndims failed"); } + // Allocate space for the dimensions + dimensions = new hsize_t[rank]; + // Get the dimensions of the existing array and store it in this array - try { - dimensions = new hsize_t[rank]; - } catch (const std::bad_alloc&) { - throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); - } int ret_value = H5Tget_array_dims2(id, dimensions); if (ret_value < 0) throw DataTypeIException("ArrayType constructor (existing id)", "H5Tget_array_dims2 failed"); @@ -75,12 +73,11 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id ) //-------------------------------------------------------------------------- ArrayType::ArrayType( const ArrayType& original ) : DataType( original ) { + // Copy the rank of the original array rank = original.rank; - try { - dimensions = new hsize_t[rank]; - } catch (const std::bad_alloc&) { - throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); - } + + // Allocate space then copy the dimensions from the original array + dimensions = new hsize_t[rank]; for (int i = 0; i < rank; i++) dimensions[i] = original.dimensions[i]; } @@ -97,16 +94,17 @@ ArrayType::ArrayType( const ArrayType& original ) : DataType( original ) //-------------------------------------------------------------------------- ArrayType::ArrayType(const DataType& base_type, int ndims, const hsize_t* dims) : DataType() { + // Call C API to create an array data type hid_t new_type_id = H5Tarray_create2(base_type.getId(), ndims, dims); if (new_type_id < 0) throw DataTypeIException("ArrayType constructor", "H5Tarray_create2 failed"); + + // Set the id and rank for this object id = new_type_id; rank = ndims; - try { - dimensions = new hsize_t[rank]; - } catch (const std::bad_alloc&) { - throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); - } + + // Allocate space then set the dimensions as provided by caller + dimensions = new hsize_t[rank]; for (int i = 0; i < rank; i++) dimensions[i] = dims[i]; } @@ -143,23 +141,19 @@ int ArrayType::getArrayNDims() //-------------------------------------------------------------------------- int ArrayType::getArrayDims(hsize_t* dims) { - // if the array's dimensions have not been stored, retrieve them via C API + // If the array's dimensions have not been stored, retrieve them via C API if (dimensions == NULL) { int ndims = H5Tget_array_dims2(id, dims); if (ndims < 0) throw DataTypeIException("ArrayType::getArrayDims", "H5Tget_array_dims2 failed"); - // store the array's info in memory + // Store the array's info in memory rank = ndims; - try { - dimensions = new hsize_t[rank]; - } catch (const std::bad_alloc&) { - throw DataTypeIException("ArrayType constructor (existing id)", "Memory allocation failed"); - } + dimensions = new hsize_t[rank]; for (int i = 0; i < rank; i++) dimensions[i] = dims[i]; } - // otherwise, simply copy what's in 'dimensions' to 'dims' + // Otherwise, simply copy what's in 'dimensions' to 'dims' for (int i = 0; i < rank; i++) dims[i] = dimensions[i]; return(rank); -- cgit v0.12 From bfdf66356924857ed6b515bbc6a0bc150b2a221e Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 1 Oct 2014 09:29:42 -0500 Subject: [svn-r25646] Fix missing endif --- config/cmake/hdf5-config-version.cmake.in | 38 +++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/config/cmake/hdf5-config-version.cmake.in b/config/cmake/hdf5-config-version.cmake.in index 63a730f..5911fa7 100644 --- a/config/cmake/hdf5-config-version.cmake.in +++ b/config/cmake/hdf5-config-version.cmake.in @@ -13,26 +13,26 @@ set (PACKAGE_VERSION "@HDF5_VERSION_STRING@") if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" ) set(PACKAGE_VERSION_COMPATIBLE FALSE) else() - -if ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@H5_VERS_MAJOR@") - - # exact match for version @H5_VERS_MAJOR@.@H5_VERS_MINOR@ - if ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") - - # compatible with any version @H5_VERS_MAJOR@.@H5_VERS_MINOR@.x - set (PACKAGE_VERSION_COMPATIBLE TRUE) + if ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@H5_VERS_MAJOR@") - if ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@H5_VERS_RELEASE@") - set (PACKAGE_VERSION_EXACT TRUE) - - if ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@H5_VERS_SUBRELEASE@") - # not using this yet - endif ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@H5_VERS_SUBRELEASE@") - endif ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@H5_VERS_RELEASE@") - else ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") - set (PACKAGE_VERSION_COMPATIBLE FALSE) - endif ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") -endif ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@H5_VERS_MAJOR@") + # exact match for version @H5_VERS_MAJOR@.@H5_VERS_MINOR@ + if ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") + + # compatible with any version @H5_VERS_MAJOR@.@H5_VERS_MINOR@.x + set (PACKAGE_VERSION_COMPATIBLE TRUE) + + if ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@H5_VERS_RELEASE@") + set (PACKAGE_VERSION_EXACT TRUE) + + if ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@H5_VERS_SUBRELEASE@") + # not using this yet + endif ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@H5_VERS_SUBRELEASE@") + endif ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@H5_VERS_RELEASE@") + else ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") + set (PACKAGE_VERSION_COMPATIBLE FALSE) + endif ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@H5_VERS_MINOR@") + endif ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@H5_VERS_MAJOR@") +endif() # if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it: if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "") -- cgit v0.12 From 87bed2c75284cfb13a1e88f34e48103d6614eedc Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 1 Oct 2014 17:02:41 -0500 Subject: [svn-r25651] Fix for: HDFFV-8715 HDF5_PARAPREFIX is ignored in parallel dense attribute and performance tests. tested on Jam w/ parallel. --- perform/perf.c | 25 +++++++++++++++++++++++-- testpar/t_dset.c | 7 ++++++- testpar/testphdf5.c | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/perform/perf.c b/perform/perf.c index f006afb..b7898ff 100644 --- a/perform/perf.c +++ b/perform/perf.c @@ -46,6 +46,9 @@ # include #endif +#ifndef HDF5_PARAPREFIX +# define HDF5_PARAPREFIX "" +#endif /* !HDF5_PARAPREFIX */ /* Macro definitions */ /* Verify: @@ -114,6 +117,8 @@ int main(int argc, char **argv) MPI_File fh; MPI_Status status; int nchars; + const char *prefix; + char *fullname=NULL; herr_t ret; /* Generic return value */ /* startup MPI and determine the rank of this process */ @@ -126,6 +131,20 @@ int main(int argc, char **argv) if (mynod == 0) printf("# Using hdf5-io calls.\n"); + /* create filename with correct prefix using HDF5_PARAPREFIX */ + prefix = HDgetenv("HDF5_PARAPREFIX"); + +#ifdef HDF5_PARAPREFIX + if (!prefix) + prefix = HDF5_PARAPREFIX; +#endif /* HDF5_PARAPREFIX */ + fullname = (char*) malloc(strlen(prefix) + strlen(opt_file) + 2); + if (strlen(prefix) > 0) + { + strcpy(fullname, prefix); + strcat(fullname, "/"); + } + strcat(fullname, opt_file); /* kindof a weird hack- if the location of the pvfstab file was * specified on the command line, then spit out this location into @@ -199,7 +218,7 @@ int main(int argc, char **argv) } /* create the parallel file */ - fid = H5Fcreate(opt_file, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + fid = H5Fcreate(fullname, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL); /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ @@ -261,7 +280,7 @@ int main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); /* reopen the file for reading */ - fid=H5Fopen(opt_file,H5F_ACC_RDONLY,acc_tpl); + fid=H5Fopen(fullname,H5F_ACC_RDONLY,acc_tpl); VRFY((fid >= 0), "", H5FATAL); /* open the dataset */ @@ -382,6 +401,8 @@ die_jar_jar_die: free(tmp); if (opt_correct) free(tmp2); + if(fullname) free(fullname); + MPI_Finalize(); return(0); diff --git a/testpar/t_dset.c b/testpar/t_dset.c index 2bc3b09..281b1c0 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -4365,6 +4365,11 @@ test_dense_attr(void) hid_t atFileSpace, atid; hsize_t atDims[1] = {10000}; herr_t status; + const char *filename; + + /* get filename */ + filename = (const char *)GetTestParameters(); + HDassert( filename != NULL ); /* set up MPI parameters */ MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); @@ -4376,7 +4381,7 @@ test_dense_attr(void) VRFY((status >= 0), "H5Pset_libver_bounds succeeded"); status = H5Pset_fapl_mpio(fpid, MPI_COMM_WORLD, MPI_INFO_NULL); VRFY((status >= 0), "H5Pset_fapl_mpio succeeded"); - fid = H5Fcreate("ph5Dense.h5", H5F_ACC_TRUNC, H5P_DEFAULT, fpid); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fpid); VRFY((fid > 0), "H5Fcreate succeeded"); status = H5Pclose(fpid); VRFY((status >= 0), "H5Pclose succeeded"); diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c index df6257f..c55e2de 100644 --- a/testpar/testphdf5.c +++ b/testpar/testphdf5.c @@ -528,7 +528,7 @@ int main(int argc, char **argv) } AddTest("denseattr", test_dense_attr, NULL, - "Store Dense Attributes", NULL); + "Store Dense Attributes", PARATESTFILE); /* Display testing information */ -- cgit v0.12 From cbd0112b16e4da4811226beb03144db4c5ed10d2 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Wed, 1 Oct 2014 23:30:53 -0500 Subject: [svn-r25654] Bug fix: HDFFV-8933 Description: Mac has changed to use the clang/clang++ compilers but compiler settings for production, debug and profile were not setup. Solution: Setup default values for PROD_CFLAGS, PROD_CPPFLAGS, DEBUG_CFLAGS, DEBUG_CPPFLAGS. PROFILE_CFLAGS and PROFILE_CPPFLAGS were set too but clang does not -pg or such for profiling. Need to fix it later. Tested: duck, swallow, and quail using --enable-production. --- config/apple | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/apple b/config/apple index ac93ea5..be0e9f9 100644 --- a/config/apple +++ b/config/apple @@ -31,6 +31,20 @@ if test "X-" = "X-$CC"; then *) CC=clang CC_BASENAME=clang + + # Production + PROD_CFLAGS="-O3" + PROD_CPPFLAGS="-O3" + + # Debug + DEBUG_CFLAGS="-g -O0" + DEBUG_CPPFLAGS="-g -O0" + + # Profile + # Use this for profiling with gprof + # Just "-g" for now. More later. + PROFILE_CFLAGS="-g" + PROFILE_CPPFLAGS="-g" ;; esac fi -- cgit v0.12 From bd9c6d829acd95ba78b07c8d286eae81d74cd1c9 Mon Sep 17 00:00:00 2001 From: Binh-Minh Ribler Date: Thu, 2 Oct 2014 09:59:01 -0500 Subject: [svn-r25658] Purpose: Fixed HDFFV-8922 Description: Added notes regarding UTF-8 and extended ASCII, provided in HDFFV-8899, to C++ API. Platforms tested: Linux/32 2.6 (jam) - only in comments --- c++/src/H5StrType.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/c++/src/H5StrType.cpp b/c++/src/H5StrType.cpp index a906b72..5195bba 100644 --- a/c++/src/H5StrType.cpp +++ b/c++/src/H5StrType.cpp @@ -146,6 +146,13 @@ StrType::StrType( const DataSet& dataset ) : AtomType () ///\brief Retrieves the character set type of this string datatype. ///\return Character set type, which can be: /// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. +///\note +/// ASCII and UTF-8 Unicode are the only currently supported character +/// encodings. Extended ASCII encodings (for example, ISO 8859) are not +/// supported. This encoding policy is not enforced by the HDF5 Library. +/// Using encodings other than ASCII and UTF-8 can lead to compatibility +/// and usability problems. See the C API entry H5Pset_char_encoding for +/// more information. ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- @@ -166,6 +173,13 @@ H5T_cset_t StrType::getCset() const ///\brief Sets character set to be used. ///\param cset - IN: character set type, which can be: /// \li \c H5T_CSET_ASCII (0) - Character set is US ASCII. +///\note +/// ASCII and UTF-8 Unicode are the only currently supported character +/// encodings. Extended ASCII encodings (for example, ISO 8859) are not +/// supported. This encoding policy is not enforced by the HDF5 Library. +/// Using encodings other than ASCII and UTF-8 can lead to compatibility +/// and usability problems. See the C API entry H5Pset_char_encoding for +/// more information. ///\exception H5::DataTypeIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -- cgit v0.12 From 26400c392b45a86e385905fd377e34603a31377a Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 2 Oct 2014 10:56:09 -0500 Subject: [svn-r25659] fix filename generation with prefix for perf test. tested h5commitest, jam & platypus parallel. --- perform/perf.c | 37 ++++++++--------------- test/h5test.c | 94 +++++++++++++++++++++++++++++++++++++++++++++------------- test/h5test.h | 4 +-- 3 files changed, 89 insertions(+), 46 deletions(-) diff --git a/perform/perf.c b/perform/perf.c index b7898ff..7d329f0 100644 --- a/perform/perf.c +++ b/perform/perf.c @@ -46,10 +46,6 @@ # include #endif -#ifndef HDF5_PARAPREFIX -# define HDF5_PARAPREFIX "" -#endif /* !HDF5_PARAPREFIX */ - /* Macro definitions */ /* Verify: * if val is false (0), print mesg and if fatal is true (non-zero), die. @@ -67,6 +63,8 @@ } \ } while(0) #define RANK 1 +#define MAX_PATH 1024 + hsize_t dims[RANK]; /* dataset dim sizes */ hsize_t block[RANK], stride[RANK], count[RANK]; hssize_t start[RANK]; @@ -93,6 +91,11 @@ char opt_file[256] = "perftest.out"; char opt_pvfstab[256] = "notset"; int opt_pvfstab_set = 0; +const char *FILENAME[] = { + opt_file, + NULL +}; + /* function prototypes */ static int parse_args(int argc, char **argv); @@ -117,8 +120,7 @@ int main(int argc, char **argv) MPI_File fh; MPI_Status status; int nchars; - const char *prefix; - char *fullname=NULL; + char filename[MAX_PATH]; herr_t ret; /* Generic return value */ /* startup MPI and determine the rank of this process */ @@ -131,21 +133,6 @@ int main(int argc, char **argv) if (mynod == 0) printf("# Using hdf5-io calls.\n"); - /* create filename with correct prefix using HDF5_PARAPREFIX */ - prefix = HDgetenv("HDF5_PARAPREFIX"); - -#ifdef HDF5_PARAPREFIX - if (!prefix) - prefix = HDF5_PARAPREFIX; -#endif /* HDF5_PARAPREFIX */ - fullname = (char*) malloc(strlen(prefix) + strlen(opt_file) + 2); - if (strlen(prefix) > 0) - { - strcpy(fullname, prefix); - strcat(fullname, "/"); - } - strcat(fullname, opt_file); - /* kindof a weird hack- if the location of the pvfstab file was * specified on the command line, then spit out this location into * the appropriate environment variable: */ @@ -217,8 +204,10 @@ int main(int argc, char **argv) } } + h5_fixname_no_suffix(FILENAME[0], acc_tpl, filename, sizeof filename); + /* create the parallel file */ - fid = H5Fcreate(fullname, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); VRFY((fid >= 0), "H5Fcreate succeeded", H5FATAL); /* define a contiquous dataset of opt_iter*nprocs*opt_block chars */ @@ -280,7 +269,7 @@ int main(int argc, char **argv) MPI_Barrier(MPI_COMM_WORLD); /* reopen the file for reading */ - fid=H5Fopen(fullname,H5F_ACC_RDONLY,acc_tpl); + fid=H5Fopen(filename,H5F_ACC_RDONLY,acc_tpl); VRFY((fid >= 0), "", H5FATAL); /* open the dataset */ @@ -401,7 +390,6 @@ die_jar_jar_die: free(tmp); if (opt_correct) free(tmp2); - if(fullname) free(fullname); MPI_Finalize(); @@ -426,6 +414,7 @@ parse_args(int argc, char **argv) break; case 'f': /* filename */ strncpy(opt_file, optarg, 255); + FILENAME[0] = opt_file; break; case 'p': /* pvfstab file */ strncpy(opt_pvfstab, optarg, 255); diff --git a/test/h5test.c b/test/h5test.c index d25b455..61a9ae0 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -92,6 +92,8 @@ MPI_Info h5_io_info_g=MPI_INFO_NULL;/* MPI INFO object for IO */ static const char *multi_letters = "msbrglo"; static herr_t h5_errors(hid_t estack, void *client_data); +static char * h5_fixname_real(const char *base_name, hid_t fapl, const char *suffix, + char *fullname, size_t size); /*------------------------------------------------------------------------- @@ -268,9 +270,59 @@ h5_reset(void) char * h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) { + return (h5_fixname_real(base_name, fapl, ".h5", fullname, size)); +} + + +/*------------------------------------------------------------------------- + * Function: h5_fixname_no_suffix + * + * Purpose: Same as h5_fixname but with no suffix appended + * + * Return: Success: The FULLNAME pointer. + * + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. + * + *------------------------------------------------------------------------- + */ +char * +h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size) +{ + return (h5_fixname_real(base_name, fapl, NULL, fullname, size)); +} + + +/*------------------------------------------------------------------------- + * Function: h5_fixname_real + * + * Purpose: Create a file name from a file base name like `test' and + * return it through the FULLNAME (at most SIZE characters + * counting the null terminator). The full name is created by + * prepending the contents of HDF5_PREFIX (separated from the + * base name by a slash) and appending a file extension based on + * the driver supplied, resulting in something like + * `ufs:/u/matzke/test.h5'. + * + * Return: Success: The FULLNAME pointer. + * + * Failure: NULL if BASENAME or FULLNAME is the null + * pointer or if FULLNAME isn't large enough for + * the result. + * + * Programmer: Robb Matzke + * Thursday, November 19, 1998 + * + *------------------------------------------------------------------------- + */ +static char * +h5_fixname_real(const char *base_name, hid_t fapl, const char *_suffix, + char *fullname, size_t size) +{ const char *prefix = NULL; - const char *suffix = ".h5"; /* suffix has default */ char *ptr, last = '\0'; + const char *suffix = _suffix; size_t i, j; hid_t driver = -1; int isppdriver = 0; /* if the driver is MPI parallel */ @@ -285,10 +337,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if((driver = H5Pget_driver(fapl)) < 0) return NULL; - if(H5FD_FAMILY == driver) - suffix = "%05d.h5"; - else if (H5FD_MULTI == driver) - suffix = NULL; + if(suffix) { + if(H5FD_FAMILY == driver) + suffix = "%05d.h5"; + else if (H5FD_MULTI == driver) + suffix = NULL; + } } /* Must first check fapl is not H5P_DEFAULT (-1) because H5FD_XXX @@ -318,11 +372,11 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) */ if(isppdriver) { #ifdef H5_HAVE_PARALLEL - /* + /* * For parallel: * First use command line option, then the environment * variable, then try the constant - */ + */ static int explained = 0; prefix = (paraprefix ? paraprefix : getenv_all(MPI_COMM_WORLD, 0, "HDF5_PARAPREFIX")); @@ -335,12 +389,12 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) if (mpi_rank == 0) printf("*** Hint ***\n" - "You can use environment variable HDF5_PARAPREFIX to " - "run parallel test files in a\n" - "different directory or to add file type prefix. E.g.,\n" - " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" - " export HDF5_PARAPREFIX\n" - "*** End of Hint ***\n"); + "You can use environment variable HDF5_PARAPREFIX to " + "run parallel test files in a\n" + "different directory or to add file type prefix. E.g.,\n" + " HDF5_PARAPREFIX=pfs:/PFS/user/me\n" + " export HDF5_PARAPREFIX\n" + "*** End of Hint ***\n"); explained = TRUE; #ifdef HDF5_PARAPREFIX @@ -352,7 +406,7 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) /* * For serial: * First use the environment variable, then try the constant - */ + */ prefix = HDgetenv("HDF5_PREFIX"); #ifdef HDF5_PREFIX @@ -425,18 +479,18 @@ h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size) return NULL; } } else if (HDstrlen(base_name) >= size) { - /* Buffer is too small */ - return NULL; + /* Buffer is too small */ + return NULL; } else { - HDstrcpy(fullname, base_name); - } + HDstrcpy(fullname, base_name); + } /* Append a suffix */ if (suffix) { - if (HDstrlen(fullname) + HDstrlen(suffix) >= size) + if (HDstrlen(fullname) + HDstrlen(suffix) >= size) return NULL; - HDstrcat(fullname, suffix); + HDstrcat(fullname, suffix); } /* Remove any double slashes in the filename */ diff --git a/test/h5test.h b/test/h5test.h index 7813b51..ce224d8 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -142,8 +142,8 @@ extern "C" { /* Generally useful testing routines */ H5TEST_DLL int h5_cleanup(const char *base_name[], hid_t fapl); -H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, - size_t size); +H5TEST_DLL char *h5_fixname(const char *base_name, hid_t fapl, char *fullname, size_t size); +H5TEST_DLL char *h5_fixname_no_suffix(const char *base_name, hid_t fapl, char *fullname, size_t size); H5TEST_DLL hid_t h5_fileaccess(void); H5TEST_DLL void h5_no_hwconv(void); H5TEST_DLL const char *h5_rmprefix(const char *filename); -- cgit v0.12 From ca6ffd477d11268cb4d37174417befe6506ae47b Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Fri, 3 Oct 2014 10:51:50 -0500 Subject: [svn-r25661] Update the default setting for the memb_addr array when use passes NULL to equally divide all the address space between all the members. Before there was one chunk of the address space not being used. tested h5committest, and multi vfd make check on jam. --- src/H5FDmulti.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index 4a62bd8..38097c8 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -491,7 +491,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, } if (!memb_addr) { for (mt=H5FD_MEM_DEFAULT; mt