diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2016-04-22 11:22:34 (GMT) |
commit | c37607eb58994041cbeaabdab5f1e9902794a3e9 (patch) | |
tree | b96792d17d5bce03ad862b556f137a7b06c1449d | |
parent | c63f96d6e78cfe98de8001b662ec685467fd65df (diff) | |
download | hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.zip hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.gz hdf5-c37607eb58994041cbeaabdab5f1e9902794a3e9.tar.bz2 |
[svn-r29759] Purpose: Code improvements
Description:
- Changed object in catch statements to reference
- Replaced old-style casts or reinterpret_cast with static_cast
- Removed unused name H5Library::need_cleanup
- Removed Exception::printError from documentation
Platforms tested:
Linux/32 2.6 (jam)
Linux/64 (platypus)
Darwin (osx1010test)
-rw-r--r-- | c++/src/H5AbstractDs.cpp | 36 | ||||
-rw-r--r-- | c++/src/H5ArrayType.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5Attribute.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5CompType.cpp | 16 | ||||
-rw-r--r-- | c++/src/H5DataSet.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5DataSpace.cpp | 6 | ||||
-rw-r--r-- | c++/src/H5DataType.cpp | 8 | ||||
-rw-r--r-- | c++/src/H5Exception.cpp | 9 | ||||
-rw-r--r-- | c++/src/H5File.cpp | 10 | ||||
-rw-r--r-- | c++/src/H5Group.cpp | 4 | ||||
-rw-r--r-- | c++/src/H5IdComponent.cpp | 2 | ||||
-rw-r--r-- | c++/src/H5Library.cpp | 7 | ||||
-rw-r--r-- | c++/src/H5Library.h | 5 | ||||
-rw-r--r-- | c++/src/H5Location.cpp | 16 | ||||
-rw-r--r-- | c++/src/H5PropList.cpp | 6 | ||||
-rw-r--r-- | c++/test/dsets.cpp | 62 | ||||
-rw-r--r-- | c++/test/h5cpputil.cpp | 20 | ||||
-rw-r--r-- | c++/test/tarray.cpp | 6 | ||||
-rw-r--r-- | c++/test/tattr.cpp | 79 | ||||
-rw-r--r-- | c++/test/tcompound.cpp | 33 | ||||
-rw-r--r-- | c++/test/tdspl.cpp | 3 | ||||
-rw-r--r-- | c++/test/testhdf5.cpp | 2 | ||||
-rw-r--r-- | c++/test/tfile.cpp | 19 | ||||
-rw-r--r-- | c++/test/tfilter.cpp | 6 | ||||
-rw-r--r-- | c++/test/th5s.cpp | 14 | ||||
-rw-r--r-- | c++/test/tlinks.cpp | 6 | ||||
-rw-r--r-- | c++/test/tobject.cpp | 6 | ||||
-rw-r--r-- | c++/test/trefer.cpp | 24 | ||||
-rw-r--r-- | c++/test/ttypes.cpp | 28 | ||||
-rw-r--r-- | c++/test/tvlstr.cpp | 31 |
30 files changed, 256 insertions, 222 deletions
diff --git a/c++/src/H5AbstractDs.cpp b/c++/src/H5AbstractDs.cpp index 8d88c53..6dee337 100644 --- a/c++/src/H5AbstractDs.cpp +++ b/c++/src/H5AbstractDs.cpp @@ -68,10 +68,10 @@ H5T_class_t AbstractDs::getTypeClass() const try { datatype_id = p_get_type(); // returned value is already validated } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getTypeClass", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getTypeClass", E.getDetailMsg()); } @@ -118,10 +118,10 @@ DataType AbstractDs::getDataType() const f_DataType_setId(&datatype, p_get_type()); return(datatype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getDataType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getDataType", E.getDetailMsg()); } } @@ -148,10 +148,10 @@ ArrayType AbstractDs::getArrayType() const arraytype.setArrayInfo(); return(arraytype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getArrayType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getArrayType", E.getDetailMsg()); } } @@ -175,10 +175,10 @@ CompType AbstractDs::getCompType() const f_DataType_setId(&comptype, p_get_type()); return(comptype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getCompType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getCompType", E.getDetailMsg()); } } @@ -202,10 +202,10 @@ EnumType AbstractDs::getEnumType() const f_DataType_setId(&enumtype, p_get_type()); return(enumtype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getEnumType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getEnumType", E.getDetailMsg()); } } @@ -229,10 +229,10 @@ IntType AbstractDs::getIntType() const f_DataType_setId(&inttype, p_get_type()); return(inttype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getIntType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getIntType", E.getDetailMsg()); } } @@ -256,10 +256,10 @@ FloatType AbstractDs::getFloatType() const f_DataType_setId(&floatype, p_get_type()); return(floatype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getFloatType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getFloatType", E.getDetailMsg()); } } @@ -283,10 +283,10 @@ StrType AbstractDs::getStrType() const f_DataType_setId(&strtype, p_get_type()); return(strtype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getStrType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getStrType", E.getDetailMsg()); } } @@ -310,10 +310,10 @@ VarLenType AbstractDs::getVarLenType() const f_DataType_setId(&varlentype, p_get_type()); return(varlentype); } - catch (DataSetIException E) { + catch (DataSetIException& E) { throw DataTypeIException("DataSet::getVarLenType", E.getDetailMsg()); } - catch (AttributeIException E) { + catch (AttributeIException& E) { throw DataTypeIException("Attribute::getVarLenType", E.getDetailMsg()); } } diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp index 9731a13..37cd8c1 100644 --- a/c++/src/H5ArrayType.cpp +++ b/c++/src/H5ArrayType.cpp @@ -112,7 +112,7 @@ ArrayType& ArrayType::operator=(const ArrayType& rhs) // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("operator="), close_error.getDetailMsg()); } diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp index 34489fa..301aaf1 100644 --- a/c++/src/H5Attribute.cpp +++ b/c++/src/H5Attribute.cpp @@ -293,7 +293,7 @@ H5std_string Attribute::getFileName() const try { return(p_get_file_name()); } - catch (IdComponentException E) { + catch (IdComponentException& E) { throw FileIException("Attribute::getFileName", E.getDetailMsg()); } } @@ -348,7 +348,7 @@ H5std_string Attribute::getName() const H5std_string attr_name(""); // attribute name to return // Preliminary call to get the size of the attribute name - ssize_t name_size = H5Aget_name(id, (size_t)0, NULL); + ssize_t name_size = H5Aget_name(id, static_cast<size_t>(0), NULL); // If H5Aget_name failed, throw exception if (name_size < 0) @@ -630,7 +630,7 @@ void Attribute::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw AttributeIException("Attribute::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -674,7 +674,7 @@ Attribute::~Attribute() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "Attribute::~Attribute - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5CompType.cpp b/c++/src/H5CompType.cpp index 82575d6..5668ec3 100644 --- a/c++/src/H5CompType.cpp +++ b/c++/src/H5CompType.cpp @@ -232,7 +232,7 @@ DataType CompType::getMemberDataType( unsigned member_num ) const f_DataType_setId(&datatype, p_get_member_type(member_num)); return(datatype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberDataType", E.getDetailMsg()); } } @@ -254,7 +254,7 @@ ArrayType CompType::getMemberArrayType( unsigned member_num ) const arraytype.setArrayInfo(); return(arraytype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberArrayType", E.getDetailMsg()); } } @@ -275,7 +275,7 @@ CompType CompType::getMemberCompType( unsigned member_num ) const f_DataType_setId(&comptype, p_get_member_type(member_num)); return(comptype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberCompType", E.getDetailMsg()); } } @@ -296,7 +296,7 @@ EnumType CompType::getMemberEnumType( unsigned member_num ) const f_DataType_setId(&enumtype, p_get_member_type(member_num)); return(enumtype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberEnumType", E.getDetailMsg()); } } @@ -317,7 +317,7 @@ IntType CompType::getMemberIntType( unsigned member_num ) const f_DataType_setId(&inttype, p_get_member_type(member_num)); return(inttype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberIntType", E.getDetailMsg()); } } @@ -338,7 +338,7 @@ FloatType CompType::getMemberFloatType( unsigned member_num ) const f_DataType_setId(&floatype, p_get_member_type(member_num)); return(floatype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberFloatType", E.getDetailMsg()); } } @@ -359,7 +359,7 @@ StrType CompType::getMemberStrType( unsigned member_num ) const f_DataType_setId(&strtype, p_get_member_type(member_num)); return(strtype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberStrType", E.getDetailMsg()); } } @@ -380,7 +380,7 @@ VarLenType CompType::getMemberVarLenType( unsigned member_num ) const f_DataType_setId(&varlentype, p_get_member_type(member_num)); return(varlentype); } - catch (DataTypeIException E) { + catch (DataTypeIException& E) { throw DataTypeIException("CompType::getMemberVarLenType", E.getDetailMsg()); } } diff --git a/c++/src/H5DataSet.cpp b/c++/src/H5DataSet.cpp index 7305347..8f5ad6f 100644 --- a/c++/src/H5DataSet.cpp +++ b/c++/src/H5DataSet.cpp @@ -781,7 +781,7 @@ void DataSet::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSetIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -841,7 +841,7 @@ DataSet::~DataSet() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "DataSet::~DataSet - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataSpace.cpp b/c++/src/H5DataSpace.cpp index 690f328..7b6289c 100644 --- a/c++/src/H5DataSpace.cpp +++ b/c++/src/H5DataSpace.cpp @@ -167,7 +167,7 @@ void DataSpace::copy( const DataSpace& like_space ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSpaceIException("DataSpace::copy", close_error.getDetailMsg()); } } // end if @@ -656,7 +656,7 @@ void DataSpace::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataSpaceIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -700,7 +700,7 @@ DataSpace::~DataSpace() { try { close(); - } catch (Exception close_error) { + } catch (Exception& close_error) { cerr << "DataSpace::~DataSpace - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp index 3e5ad0f..b7d787d 100644 --- a/c++/src/H5DataType.cpp +++ b/c++/src/H5DataType.cpp @@ -179,7 +179,7 @@ void DataType::copy( const DataType& like_type ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -204,7 +204,7 @@ void DataType::copy(const DataSet& dset) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -723,7 +723,7 @@ void DataType::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw DataTypeIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -776,7 +776,7 @@ DataType::~DataType() { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << inMemFunc("~DataType - ") << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Exception.cpp b/c++/src/H5Exception.cpp index 270b232..7b81066 100644 --- a/c++/src/H5Exception.cpp +++ b/c++/src/H5Exception.cpp @@ -312,14 +312,15 @@ void Exception::printErrorStack(FILE* stream, hid_t err_stack) //-------------------------------------------------------------------------- // Function: Exception::printError -///\brief Prints the error stack in a default manner. This member -/// function is replaced by the static function printErrorStack -/// and will be removed from the next major release. -///\param stream - IN: File pointer +// Purpose: Prints the error stack in a default manner. This member +// function is replaced by the static function printErrorStack +// and will be removed from the next major release. +// Parameter stream - IN: File pointer // Programmer Binh-Minh Ribler - 2000 // Description: // This function can be removed in next major release. // -BMR, 2014/04/24 +// Removed from documentation. -BMR, 2016/03/23 //-------------------------------------------------------------------------- void Exception::printError(FILE* stream) const { diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index 67dda34..e63694a 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -88,7 +88,7 @@ H5File::H5File( const char* name, unsigned int flags, const FileCreatPropList& c { try { p_get_file(name, flags, create_plist, access_plist); - } catch (FileIException open_file) { + } catch (FileIException& open_file) { throw open_file; } } @@ -113,7 +113,7 @@ H5File::H5File( const H5std_string& name, unsigned int flags, const FileCreatPro { try { p_get_file(name.c_str(), flags, create_plist, access_plist); - } catch (FileIException open_file) { + } catch (FileIException& open_file) { throw open_file; } } @@ -245,7 +245,7 @@ void H5File::openFile(const char* name, unsigned int flags, const FileAccPropLis try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException("H5File::openFile", close_error.getDetailMsg()); } @@ -294,7 +294,7 @@ void H5File::reOpen() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException("H5File::reOpen", close_error.getDetailMsg()); } @@ -650,7 +650,7 @@ H5File::~H5File() { try { close(); - } catch (Exception close_error) { + } catch (Exception& close_error) { cerr << "H5File::~H5File - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5Group.cpp b/c++/src/H5Group.cpp index f9aabcb..9d27b79 100644 --- a/c++/src/H5Group.cpp +++ b/c++/src/H5Group.cpp @@ -156,7 +156,7 @@ void Group::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw GroupIException("Group::p_setId", close_error.getDetailMsg()); } // reset object's id to the given id @@ -221,7 +221,7 @@ Group::~Group() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "Group::~Group - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 60735f0..4f8c4a2 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -207,7 +207,7 @@ IdComponent& IdComponent::operator=( const IdComponent& rhs ) // Note: a = b, so there are two objects with the same hdf5 id // that's why incRefCount is needed, and it is called by setId } - catch (Exception close_error) { + catch (Exception& close_error) { throw FileIException(inMemFunc("operator="), close_error.getDetailMsg()); } } diff --git a/c++/src/H5Library.cpp b/c++/src/H5Library.cpp index be80fe4..471dbad 100644 --- a/c++/src/H5Library.cpp +++ b/c++/src/H5Library.cpp @@ -37,13 +37,6 @@ namespace H5 { #endif -#ifndef DOXYGEN_SHOULD_SKIP_THIS - -// This static variable is unused, will be removed in future releases. -bool H5Library::need_cleanup = false; - -#endif // DOXYGEN_SHOULD_SKIP_THIS - //-------------------------------------------------------------------------- // Function: H5Library::open (static) ///\brief Initializes the HDF5 library. diff --git a/c++/src/H5Library.h b/c++/src/H5Library.h index 336f9c8..308881b 100644 --- a/c++/src/H5Library.h +++ b/c++/src/H5Library.h @@ -29,11 +29,6 @@ namespace H5 { */ class H5_DLLCPP H5Library { public: -#ifndef DOXYGEN_SHOULD_SKIP_THIS - static bool need_cleanup; // indicates if H5close should be called - // - unused, will be removed in future releases. -#endif // DOXYGEN_SHOULD_SKIP_THIS - // Initializes the HDF5 library. static void open(); diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp index e2b68ae..c4debba 100644 --- a/c++/src/H5Location.cpp +++ b/c++/src/H5Location.cpp @@ -230,7 +230,7 @@ int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_ userData->location = this; // call the C library routine H5Aiterate2 to iterate the attributes - hsize_t idx = _idx ? (hsize_t)*_idx : 0; + hsize_t idx = _idx ? static_cast<hsize_t>(*_idx) : 0; int ret_value = H5Aiterate2(getId(), H5_INDEX_NAME, H5_ITER_INC, &idx, userAttrOpWrpr, reinterpret_cast<void *>(userData)); @@ -387,7 +387,7 @@ H5std_string H5Location::getFileName() const try { return(p_get_file_name()); } - catch (LocationException E) { + catch (LocationException& E) { throw FileIException(inMemFunc("getFileName"), E.getDetailMsg()); } } @@ -634,7 +634,7 @@ void H5Location::reference(void* ref, const char* name, const DataSpace& dataspa try { p_reference(ref, name, dataspace.getId(), ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -660,7 +660,7 @@ void H5Location::reference(void* ref, const H5std_string& name, const DataSpace& try { p_reference(ref, name.c_str(), dataspace.getId(), ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -684,7 +684,7 @@ void H5Location::reference(void* ref, const char* name, H5R_type_t ref_type) con try { p_reference(ref, name, -1, ref_type); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("reference"), E.getDetailMsg()); } } @@ -803,7 +803,7 @@ H5G_obj_t H5Location::getObjType(void *ref, H5R_type_t ref_type) const try { return(p_get_obj_type(ref, ref_type)); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("getObjType"), E.getDetailMsg()); } } @@ -859,7 +859,7 @@ H5O_type_t H5Location::getRefObjType(void *ref, H5R_type_t ref_type) const try { return(p_get_ref_obj_type(ref, ref_type)); } - catch (ReferenceException E) { + catch (ReferenceException& E) { throw ReferenceException(inMemFunc("getRefObjType"), E.getDetailMsg()); } } @@ -924,7 +924,7 @@ DataSpace H5Location::getRegion(void *ref, H5R_type_t ref_type) const f_DataSpace_setId(&dataspace, space_id); return(dataspace); } - catch (DataSpaceIException E) { + catch (DataSpaceIException& E) { throw ReferenceException(inMemFunc("getRegion"), E.getDetailMsg()); } } diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index b954191..6655900 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -169,7 +169,7 @@ void PropList::copy( const PropList& like_plist ) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw PropListIException(inMemFunc("copy"), close_error.getDetailMsg()); } @@ -301,7 +301,7 @@ void PropList::p_setId(const hid_t new_id) try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { throw PropListIException(inMemFunc("p_setId"), close_error.getDetailMsg()); } // reset object's id to the given id @@ -747,7 +747,7 @@ PropList::~PropList() try { close(); } - catch (Exception close_error) { + catch (Exception& close_error) { cerr << "PropList::~PropList - " << close_error.getDetailMsg() << endl; } } diff --git a/c++/test/dsets.cpp b/c++/test/dsets.cpp index 60e875c..6c27895 100644 --- a/c++/test/dsets.cpp +++ b/c++/test/dsets.cpp @@ -116,7 +116,7 @@ test_create( H5File& file) // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (FileIException E) // catching invalid creating dataset + catch (FileIException& E) // catching invalid creating dataset {} // do nothing, exception expected // Open the dataset we created above and then close it. This is one @@ -148,7 +148,7 @@ test_create( H5File& file) // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::openDataSet", "Attempted to open a non-existent dataset"); } - catch (FileIException E ) // catching creating non-existent dataset + catch (FileIException& E ) // catching creating non-existent dataset {} // do nothing, exception expected // Create a new dataset that uses chunked storage instead of the default @@ -170,7 +170,7 @@ test_create( H5File& file) return 0; } // outer most try block - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -181,7 +181,7 @@ test_create( H5File& file) return -1; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_create", __LINE__, __FILE__); @@ -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(reinterpret_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.write(static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Read the dataset back - dataset.read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset.read (static_cast<void*>(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++) @@ -267,7 +267,7 @@ test_simple_io( H5File& file) } // end try // catch all dataset, space, plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -339,7 +339,7 @@ test_datasize(FileAccPropList &fapl) } // end try // catch all dataset, space, plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -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 (reinterpret_cast<void*>(out), PredType::STD_I32LE); + dataset.write (static_cast<void*>(out), PredType::STD_I32LE); // Read data with byte order conversion - dataset.read (reinterpret_cast<void*>(in), PredType::STD_I32BE); + dataset.read (static_cast<void*>(in), PredType::STD_I32BE); // Check for (int i = 0; i < 1000000; i++) { @@ -419,7 +419,7 @@ test_tconv( H5File& file) } // end try // catch all dataset and space exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -504,6 +504,7 @@ test_compression(H5File& file) points[i][j] = static_cast<int>(n++); } } + char* tconv_buf = new char [1000]; DataSet* dataset = NULL; try @@ -539,7 +540,7 @@ test_compression(H5File& file) */ SUBTEST("Compression (uninitialized read)"); - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); for (i=0; i<size[0]; i++) { for (j=0; j<size[1]; j++) { @@ -569,7 +570,7 @@ test_compression(H5File& file) } } - dataset->write (reinterpret_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); PASSED(); @@ -580,7 +581,7 @@ test_compression(H5File& file) SUBTEST("Compression (read)"); // Read the dataset back - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast<void*>(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 +610,10 @@ test_compression(H5File& file) points[i][j] = rand (); } } - dataset->write (reinterpret_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); // Read the dataset back and check it - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast<void*>(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 +638,7 @@ test_compression(H5File& file) delete dataset; dataset = new DataSet (file.openDataSet (DSET_COMPRESS_NAME)); - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast<void*>(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 +668,8 @@ test_compression(H5File& file) } } space1.selectHyperslab( H5S_SELECT_SET, hs_size, hs_offset ); - dataset->write (reinterpret_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer); - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer); + dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, space1, space1, xfer); + dataset->read (static_cast<void*>(check), PredType::NATIVE_INT, space1, space1, xfer); // Check that the values read are the same as the values written for (i=0; i<hs_size[0]; i++) { @@ -714,8 +715,8 @@ test_compression(H5File& file) DataSpace space2 (2, size, NULL); dataset = new DataSet (file.createDataSet (DSET_BOGUS_NAME, PredType::NATIVE_INT, space2, dscreatplist)); - dataset->write (reinterpret_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); - dataset->read (reinterpret_cast<void*>(check), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->write (static_cast<void*>(points), PredType::NATIVE_INT, DataSpace::ALL, DataSpace::ALL, xfer); + dataset->read (static_cast<void*>(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++) @@ -738,7 +739,7 @@ test_compression(H5File& file) } // end try // catch all dataset, file, space, and plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -824,7 +825,7 @@ test_multiopen (H5File& file) } // end try block // catch all dataset, file, space, and plist exceptions - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -907,7 +908,7 @@ test_types(H5File& file) } // end try block of bitfield_1 // catch exceptions thrown in try block of bitfield_1 - catch (Exception E) + catch (Exception& E) { cerr << " FAILED" << endl; cerr << " <<< " << "bitfield_1: " << E.getFuncName() @@ -939,7 +940,8 @@ test_types(H5File& file) } // end try block of bitfield_2 // catch exceptions thrown in try block of bitfield_2 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "bitfield_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -971,7 +973,8 @@ test_types(H5File& file) } // end try block of opaque_1 // catch exceptions thrown in try block of opaque_1 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "opaque_1: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -1004,7 +1007,8 @@ test_types(H5File& file) } //end try block of opaque_2 // catch exceptions thrown in try block of opaque_2 - catch (Exception E) { + catch (Exception& E) + { cerr << " FAILED" << endl; cerr << " <<< " << "opaque_2: " << E.getFuncName() << " - " << E.getDetailMsg() << " >>>" << endl << endl; @@ -1019,7 +1023,7 @@ test_types(H5File& file) return 0; } // end top try block - catch (Exception E) + catch (Exception& E) { return -1; } @@ -1084,7 +1088,7 @@ void test_dset() nerrors += test_datasize(fapl) <0 ? 1:0; } - catch (Exception E) + catch (Exception& E) { test_report(nerrors, H5std_string(" Dataset")); } diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp index 9bbb183..05a4d9a 100644 --- a/c++/test/h5cpputil.cpp +++ b/c++/test/h5cpputil.cpp @@ -98,7 +98,7 @@ int test_report( int nerrors, const H5std_string& testname ) void issue_fail_msg(const char* where, int line, const char* file_name, const char* message) { - //if (GetTestVerbosity()>=VERBO_HI) + if (GetTestVerbosity()>=VERBO_HI) { cerr << endl; cerr << ">>> FAILED in " << where << " at line " << line @@ -121,7 +121,7 @@ void issue_fail_msg(const char* where, int line, const char* file_name, void issue_fail_msg(const char* where, int line, const char* file_name, const char* func_name, const char* message) { - //if (GetTestVerbosity()>=VERBO_HI) + if (GetTestVerbosity()>=VERBO_HI) { cerr << endl; cerr << ">>> FAILED in " << where << ": " << func_name << endl << @@ -156,8 +156,8 @@ int check_values (hsize_t i, hsize_t j, int apoint, int acheck) if (apoint != acheck) { cerr << " Read different values than written.\n" << endl; - cerr << " At index " << (unsigned long)i << "," << - (unsigned long)j << endl; + cerr << " At index " << static_cast<unsigned long>(i) << "," << + static_cast<unsigned long>(j) << endl; return -1; } return 0; @@ -212,10 +212,10 @@ InvalidActionException::InvalidActionException():Exception(){} // which the failure should have occurred but didn't, and a // message explaining why it should fail. // Parameters -// func_name - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- -InvalidActionException::InvalidActionException(const H5std_string func_name, const H5std_string message) : Exception(func_name, message) {} +InvalidActionException::InvalidActionException(const H5std_string func, const H5std_string message) : Exception(func, message) {} //-------------------------------------------------------------------------- // Function: InvalidActionException destructor @@ -234,10 +234,10 @@ TestFailedException::TestFailedException():Exception(){} // which the failure should have occurred but didn't, and a // message explaining why it should fail. // Parameters -// func_name - IN: Name of the function where failure should occur -// message - IN: Message +// func - IN: Name of the function where failure should occur +// message - IN: Message //-------------------------------------------------------------------------- -TestFailedException::TestFailedException(const H5std_string func_name, const H5std_string message) : Exception(func_name, message) {} +TestFailedException::TestFailedException(const H5std_string func, const H5std_string message) : Exception(func, message) {} //-------------------------------------------------------------------------- // Function: TestFailedException destructor diff --git a/c++/test/tarray.cpp b/c++/test/tarray.cpp index a6cbae4..5d78b3c 100644 --- a/c++/test/tarray.cpp +++ b/c++/test/tarray.cpp @@ -269,7 +269,8 @@ static void test_array_compound_array() file1.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_array_compound_array", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -343,7 +344,8 @@ static void test_array_assignment() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_array_assignment", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_array_assignment() diff --git a/c++/test/tattr.cpp b/c++/test/tattr.cpp index 936ee63..e8c2a78 100644 --- a/c++/test/tattr.cpp +++ b/c++/test/tattr.cpp @@ -164,7 +164,7 @@ static void test_attr_basic_write() // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -223,7 +223,7 @@ static void test_attr_basic_write() throw InvalidActionException("H5Group::createAttribute", "Attempting to create an existing attribute"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -237,7 +237,8 @@ static void test_attr_basic_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_basic_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_basic_write() @@ -371,7 +372,8 @@ static void test_attr_getname() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_getname()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_getname() @@ -481,7 +483,8 @@ static void test_attr_rename() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_rename()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_rename() @@ -549,7 +552,8 @@ static void test_attr_basic_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_basic_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_basic_read() @@ -599,7 +603,7 @@ static void test_attr_compound_write() try { Attribute invalid_attr = dataset.createAttribute (ATTR4_NAME, comp_type, sid2); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write complex attribute data @@ -608,7 +612,8 @@ static void test_attr_compound_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_compound_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_compound_write() @@ -743,7 +748,8 @@ static void test_attr_compound_read() verify_val(attr_name, ATTR4_NAME, "Attribute::getName", __LINE__, __FILE__); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -758,7 +764,8 @@ static void test_attr_compound_read() PASSED(); } // end try block - catch (FileIException E) { + catch (FileIException& E) + { issue_fail_msg("test_attr_compound_read()", __LINE__, __FILE__, "Unable to truncate file, possibly because some objects are left opened"); } } // test_attr_compound_read() @@ -803,7 +810,7 @@ static void test_attr_scalar_write() // continuation here, that means no exception has been thrown throw InvalidActionException("H5File::createDataSet", "Library allowed overwrite of existing dataset"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write attribute information @@ -812,7 +819,8 @@ static void test_attr_scalar_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_scalar_write() @@ -856,7 +864,8 @@ static void test_attr_scalar_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_scalar_read() @@ -919,7 +928,7 @@ static void test_attr_mult_write() // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::createAttribute", "Attempting to create a duplicate attribute"); } - catch (AttributeIException E) // catching invalid creating attribute + catch (AttributeIException& E) // catching invalid creating attribute {} // do nothing, exception expected // Write 3rd attribute information @@ -928,7 +937,8 @@ static void test_attr_mult_write() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_mult_write()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_mult_write() @@ -1118,7 +1128,8 @@ static void test_attr_mult_read() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_mult_read()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_mult_read() @@ -1153,7 +1164,7 @@ static void test_attr_delete() // Verify the name of the only file attribute left Attribute fattr = fid1.openAttribute((unsigned)0); - H5std_string attr_name = fattr.getName(); + attr_name = fattr.getName(); verify_val(attr_name, FATTR1_NAME, "Attribute::getName", __LINE__, __FILE__); fattr.close(); @@ -1173,7 +1184,7 @@ static void test_attr_delete() // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::removeAttr", "Attempting to remove non-existing attribute"); } - catch (AttributeIException E) // catching invalid removing attribute + catch (AttributeIException& E) // catching invalid removing attribute {} // do nothing, exception expected // Test deleting dataset's attributes @@ -1234,7 +1245,8 @@ static void test_attr_delete() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_delete()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_delete() @@ -1391,7 +1403,8 @@ static void test_attr_dtype_shared() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_dtype_shared()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dtype_shared() @@ -1515,7 +1528,8 @@ static void test_string_attr() PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_string_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_string_attr() @@ -1559,10 +1573,12 @@ static void test_attr_exists() PASSED(); } // end try block - catch (InvalidActionException E) { + catch (InvalidActionException& E) + { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_exists()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_exists() @@ -1621,8 +1637,8 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // Retrieve limits for compact/dense attribute storage and verify them dcpl.getAttrPhaseChange(max_compact, min_dense); - verify_val(max_compact, 7, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); - verify_val(min_dense, 5, "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(max_compact, static_cast<unsigned>(7), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); + verify_val(min_dense, static_cast<unsigned>(5), "DSetCreatPropList::getAttrPhaseChange",__LINE__,__FILE__); // Close property list dcpl.close(); @@ -1664,13 +1680,14 @@ static void test_attr_dense_create(FileCreatPropList& fcpl, // continuation here, that means no exception has been thrown throw InvalidActionException("DataSet::createAttribute", "Maximum number of attributes has been reached"); } - catch (AttributeIException E) // catching invalid action + catch (AttributeIException& E) // catching invalid action {} // do nothing, exception expected PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_dense_create()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_dense_create() @@ -1707,7 +1724,7 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, // continuation here, that means no exception has been thrown throw InvalidActionException("DSetCreatPropList::getAttrCrtOrder", "Indexing cannot be set alone, order tracking is required"); } - catch (PropListIException E) // catching invalid action + catch (PropListIException& E) // catching invalid action {} // do nothing, exception expected // Set attribute creation order tracking & indexing for object then @@ -1754,7 +1771,8 @@ static void test_attr_corder_create_basic(FileCreatPropList& fcpl, PASSED(); } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr_corder_create_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr_corder_create_basic() @@ -1843,7 +1861,8 @@ void test_attr() } // end for } // end try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_attr()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_attr() diff --git a/c++/test/tcompound.cpp b/c++/test/tcompound.cpp index dbf2f0c..e08c81d 100644 --- a/c++/test/tcompound.cpp +++ b/c++/test/tcompound.cpp @@ -78,8 +78,8 @@ static void test_compound_1() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_1 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_1() @@ -200,8 +200,8 @@ static void test_compound_2() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_2 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -322,8 +322,8 @@ static void test_compound_3() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_3 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -454,8 +454,8 @@ static void test_compound_4() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_4 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -558,8 +558,8 @@ static void test_compound_5() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_5 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } @@ -655,8 +655,8 @@ static void test_compound_6() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_6 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_6() @@ -714,7 +714,7 @@ static void test_compound_7() tid2.insertMember("d", HOFFSET(s2_typ_t, d), PredType::NATIVE_DOUBLE); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("CompType::insertMember", "Attempted to insert field past end of compound data type."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} /* Release resources */ tid1.close(); @@ -722,8 +722,8 @@ static void test_compound_7() PASSED(); } // end of try block - catch (Exception E) { -cerr << "test_compound_7 in catch" << endl; + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_7() @@ -812,7 +812,8 @@ static void test_compound_set_size() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg()); } } // test_compound_set_size() diff --git a/c++/test/tdspl.cpp b/c++/test/tdspl.cpp index 5c1d953..ab93c26 100644 --- a/c++/test/tdspl.cpp +++ b/c++/test/tdspl.cpp @@ -114,7 +114,8 @@ static void test_transfplist() PASSED(); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_transfplist", __LINE__, __FILE__, E.getCDetailMsg()); } } diff --git a/c++/test/testhdf5.cpp b/c++/test/testhdf5.cpp index b29c6fb..b3415f1 100644 --- a/c++/test/testhdf5.cpp +++ b/c++/test/testhdf5.cpp @@ -110,7 +110,7 @@ Comment out tests that are not done yet */ AddTest("enum", test_enum, cleanup_enum, "Enum Data Types", NULL); */ } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("Tests failed", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tfile.cpp b/c++/test/tfile.cpp index f84ce3a..4ff15ce 100644 --- a/c++/test/tfile.cpp +++ b/c++/test/tfile.cpp @@ -116,7 +116,7 @@ static void test_file_create() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File constructor", "Attempted to create an existing file."); } - catch( FileIException E ) // catch truncating existing file + catch (FileIException& E) // catch truncating existing file {} // do nothing, FAIL expected // Close file1 @@ -181,7 +181,7 @@ static void test_file_create() // Close first file delete file1; } - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " *FAILED*" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; @@ -189,7 +189,7 @@ static void test_file_create() delete file1; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (file1 != NULL) // clean up @@ -268,7 +268,7 @@ static void test_file_create() PASSED(); } // catch all exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_file_create()", __LINE__, __FILE__, E.getCDetailMsg()); if (tmpl1 != NULL) // clean up @@ -505,7 +505,8 @@ static void test_file_name() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_file_name()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -551,7 +552,7 @@ static void test_file_attribute() // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5File createAttribute", "Attempted to create an existing attribute."); } - catch( AttributeIException E ) // catch creating existing attribute + catch (AttributeIException& E) // catch creating existing attribute {} // do nothing, FAIL expected // Create a new dataset @@ -618,7 +619,8 @@ static void test_file_attribute() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_file_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_file_attribute() @@ -705,7 +707,8 @@ static void test_libver_bounds_real( // Everything should be closed as they go out of scope } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_libver_bounds_real()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tfilter.cpp b/c++/test/tfilter.cpp index ff3901d..19549b3 100644 --- a/c++/test/tfilter.cpp +++ b/c++/test/tfilter.cpp @@ -148,7 +148,7 @@ static void test_null_filter() } // end of try // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_null_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -232,7 +232,7 @@ static void test_szip_filter(H5File& file1) } // end of try // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_szip_filter()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -280,7 +280,7 @@ void test_filters() test_null_filter(); test_szip_filter(file1); } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_filters()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/th5s.cpp b/c++/test/th5s.cpp index b7a39b4..181c09f 100644 --- a/c++/test/th5s.cpp +++ b/c++/test/th5s.cpp @@ -213,13 +213,13 @@ static void test_h5s_basic() PASSED(); } // end of try block - catch (InvalidActionException E) + catch (InvalidActionException& E) { cerr << " FAILED" << endl; cerr << " <<< " << E.getDetailMsg() << " >>>" << endl << endl; } // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_basic()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -283,7 +283,7 @@ static void test_h5s_scalar_write() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -343,7 +343,7 @@ static void test_h5s_scalar_read() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); @@ -399,7 +399,7 @@ static void test_h5s_null() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_h5s_null()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -471,7 +471,7 @@ static void test_h5s_compound_scalar_write() PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_write()", __LINE__, __FILE__, E.getCDetailMsg()); @@ -545,7 +545,7 @@ static void test_h5s_compound_scalar_read() } // end if PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { // all the exceptions caused by negative returned values by C APIs issue_fail_msg("test_h5s_compound_scalar_read()", __LINE__, __FILE__, E.getCDetailMsg()); diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index 57738d7..a3eb690 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -415,7 +415,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) verify_val(reclink_val, "/grp1/recursive", "H5File::getLinkval grp1/recursive", __LINE__, __FILE__); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -441,7 +441,7 @@ static void test_basic_links(hid_t fapl_id, hbool_t new_format) PASSED(); } // end of try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_basic_links()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -630,7 +630,7 @@ void test_links() /* nerrors += external_reset_register() < 0 ? 1 : 0; */ } - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_links()", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tobject.cpp b/c++/test/tobject.cpp index 2381ec2..046e67a 100644 --- a/c++/test/tobject.cpp +++ b/c++/test/tobject.cpp @@ -148,7 +148,7 @@ static void test_get_objname() } // try block // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objname", __LINE__, __FILE__); } @@ -233,7 +233,7 @@ static void test_get_objname_ontypes() PASSED(); } // end top try block - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objname_ontypes", __LINE__, __FILE__); } @@ -298,7 +298,7 @@ static void test_get_objtype() } // try block // catch all other exceptions - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_get_objtype", __LINE__, __FILE__); } diff --git a/c++/test/trefer.cpp b/c++/test/trefer.cpp index 9d072be..1974541 100644 --- a/c++/test/trefer.cpp +++ b/c++/test/trefer.cpp @@ -144,19 +144,19 @@ test_reference_params(void) /* Test parameters to H5Location::reference */ try { file1->reference(NULL, "/Group1/Dataset1"); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], NULL); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], ""); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_MAXTYPE); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail try { file1->reference(&wbuf[0], "/Group1/Dataset1", H5R_DATASET_REGION); - } catch (ReferenceException E) {} // We expect this to fail + } catch (ReferenceException& E) {} // We expect this to fail // Close resources dataset.close(); @@ -170,7 +170,8 @@ test_reference_params(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_param()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -330,7 +331,7 @@ static void test_reference_obj(void) try { H5std_string read_comment_tmp = group.getComment(NULL); } - catch (Exception E) {} // We expect this to fail + catch (Exception& E) {} // We expect this to fail // Close group group.close(); @@ -361,7 +362,8 @@ static void test_reference_obj(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_obj()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -489,7 +491,8 @@ test_reference_group(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_group()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } @@ -780,7 +783,8 @@ test_reference_region_1D(void) PASSED(); } // end try - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_reference_region_1D()",__LINE__,__FILE__, E.getCFuncName(), E.getCDetailMsg()); } diff --git a/c++/test/ttypes.cpp b/c++/test/ttypes.cpp index 971a06f..c65d6a5 100644 --- a/c++/test/ttypes.cpp +++ b/c++/test/ttypes.cpp @@ -124,7 +124,8 @@ static void test_classes() } PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_classes", __LINE__, __FILE__, E.getCDetailMsg()); } } @@ -180,7 +181,8 @@ static void test_copy() PASSED(); } - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_copy", __LINE__, __FILE__, E.getCDetailMsg()); } } @@ -291,7 +293,8 @@ static void test_query() PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_query", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_query @@ -334,7 +337,7 @@ static void test_transient () Attribute attr(type.createAttribute("attr1", PredType::NATIVE_INT, space)); // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("H5Object::createAttribute", "Attempted to commit a predefined datatype."); - } catch (AttributeIException err) {} // do nothing, failure expected + } catch (AttributeIException& err) {} // do nothing, failure expected // Create a dataset from a transient datatype // type.close(); - put trace in H5Tclose to make sure it's closed @@ -348,7 +351,7 @@ static void test_transient () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::setPrecision", "Dataset datatypes should not be modifiable!"); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} itype.close(); // Get a copy of the dataset's datatype by applying DataType::copy() @@ -369,7 +372,8 @@ static void test_transient () space.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_transient", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_transient @@ -414,7 +418,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("PredType::commit", "Attempted to commit a predefined datatype."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} // Copy a predefined datatype and commit the copy. IntType itype(PredType::NATIVE_INT); @@ -433,7 +437,8 @@ static void test_named () // no matching prototype atype.commit(const_grp, "random uchar"); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_named", __LINE__, __FILE__, "Commit at const group"); } @@ -447,7 +452,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::setPrecision", "Attempted to modify a committed datatype."); - } catch (DataTypeIException err) {} + } catch (DataTypeIException& err) {} // We should not be able to re-commit a committed type try { @@ -455,7 +460,7 @@ static void test_named () // Should FAIL but didn't, so throw an invalid action exception throw InvalidActionException("IntType::commit", "Attempted to re-commit a committed datatype."); - } catch (DataTypeIException err) {} // do nothing, failure expected + } catch (DataTypeIException& err) {} // do nothing, failure expected // It should be possible to define an attribute for the named type Attribute attr1 = itype.createAttribute("attr1", PredType::NATIVE_UCHAR, space); @@ -529,7 +534,8 @@ static void test_named () file.close(); PASSED(); } // end of try block - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_named", __LINE__, __FILE__, E.getCDetailMsg()); } diff --git a/c++/test/tvlstr.cpp b/c++/test/tvlstr.cpp index 7c81a8e..6ec7f25 100644 --- a/c++/test/tvlstr.cpp +++ b/c++/test/tvlstr.cpp @@ -207,7 +207,8 @@ static void test_vlstring_dataset() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -306,7 +307,7 @@ static void test_vlstring_array_dataset() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstring_array_dataset()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -427,7 +428,7 @@ static void test_vlstrings_special() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstrings_special()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -513,7 +514,7 @@ static void test_vlstring_type() } // end try block // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_vlstring_type()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -592,7 +593,7 @@ static void test_compact_vlstring() } // end try // Catch all exceptions. - catch (Exception E) + catch (Exception& E) { issue_fail_msg("test_compact_vlstrings()", __LINE__, __FILE__, E.getCDetailMsg()); } @@ -682,7 +683,8 @@ static void test_vlstring_attribute() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstring_attribute() @@ -743,7 +745,8 @@ static void test_read_vl_string_attribute() } // end try // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_read_vl_string_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_read_vl_string_attribute @@ -814,7 +817,8 @@ static void test_vlstring_array_attribute() } // end try block // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vlstring_array_attribute()", __LINE__, __FILE__, E.getCDetailMsg()); } } // test_vlstring_array_attribute() @@ -829,10 +833,10 @@ static void write_scalar_dset(H5File& file, DataType& type, DataSpace& space, dset.write(&data, type, space, space); dset.close(); } // end try - catch (FileIException ferr) { + catch (FileIException& ferr) { throw; } - catch (DataSetIException derr) { + catch (DataSetIException& derr) { throw; } } @@ -853,10 +857,10 @@ static void read_scalar_dset(H5File& file, DataType& type, DataSpace& space, HDfree(data_read); } // end try - catch (FileIException ferr) { + catch (FileIException& ferr) { throw; } - catch (DataSetIException derr) { + catch (DataSetIException& derr) { throw; } } @@ -936,7 +940,8 @@ static void test_vl_rewrite() } // end try // Catch all exceptions. - catch (Exception E) { + catch (Exception& E) + { issue_fail_msg("test_vl_rewrite()", __LINE__, __FILE__, E.getCDetailMsg()); } } // end test_vl_rewrite() |