summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2001-12-14 03:34:57 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2001-12-14 03:34:57 (GMT)
commit7e494907c88efd18aa9756fdf27ebcccf4906bbc (patch)
tree54d04a458f55a01bb0f016688c447178cde60493
parent791d110501f057055b14c503b7a60282d2059dd1 (diff)
downloadhdf5-7e494907c88efd18aa9756fdf27ebcccf4906bbc.zip
hdf5-7e494907c88efd18aa9756fdf27ebcccf4906bbc.tar.gz
hdf5-7e494907c88efd18aa9756fdf27ebcccf4906bbc.tar.bz2
[svn-r4724]
Purpose: Eliminated warnings Description: 1. H5CommonFG.cpp: On IRIX and Windows 98, if a function, that is declared to return a value, throws an exception in "else" statement, the compiler still complains that the function doesn't return a value. 2. Others: H5IdComponent::operator= shouldn't be virtual because the subclass' operator= have different type for the rhs argument. Solution: 1. Replaced: if (something valid) return a value else throw an exception with: if (something invalid) throw an exception return a value 2. Removed 'virtual' Platforms tested: FreeBSD 4.4 (hawkwind) SunOS 5.7 (arabica) Linux 6.2 (eirene)
-rw-r--r--c++/src/H5CommonFG.cpp66
-rw-r--r--c++/src/H5DataSpace.h2
-rw-r--r--c++/src/H5DataType.cpp10
-rw-r--r--c++/src/H5DataType.h5
-rw-r--r--c++/src/H5IdComponent.h2
-rw-r--r--c++/src/H5PredType.cpp5
-rw-r--r--c++/src/H5PredType.h2
-rw-r--r--c++/src/H5PropList.h2
8 files changed, 39 insertions, 55 deletions
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index ae6a2bd..80cfb66 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -47,16 +47,15 @@ Group CommonFG::createGroup( const char* name, size_t size_hint ) const
// location id which can be a file id or a group id
hid_t group_id = H5Gcreate( getLocId(), name, size_hint );
- // If the group id is valid, create and return the Group object
+ // If the creation of the group failed, throw an exception
if( group_id > 0 )
{
- Group group( group_id );
- return( group );
- }
- else
- {
throwException("createGroup", "H5Gcreate failed");
}
+
+ // No failure, create and return the Group object
+ Group group( group_id );
+ return( group );
}
// Opens an existing group in a location which can be a file or another group
@@ -70,16 +69,15 @@ Group CommonFG::openGroup( const char* name ) const
// location id which can be a file id or a group id
hid_t group_id = H5Gopen( getLocId(), name );
- // If the group id is valid, create and return the Group object
- if( group_id > 0 )
- {
- Group group( group_id );
- return( group );
- }
- else
+ // If the opening of the group failed, throw an exception
+ if( group_id <= 0 )
{
throwException("openGroup", "H5Gopen failed");
}
+
+ // No failure, create and return the Group object
+ Group group( group_id );
+ return( group );
}
// Creates a new dataset at this location.
@@ -97,16 +95,13 @@ DataSet CommonFG::createDataSet( const char* name, const DataType& data_type, co
// Call C routine H5Dcreate to create the named dataset
hid_t dataset_id = H5Dcreate( getLocId(), name, type_id, space_id, create_plist_id );
- // If the dataset id is valid, create and return the DataSet object
- if( dataset_id > 0 )
- {
- DataSet dataset( dataset_id );
- return( dataset );
- }
- else
- {
+ // If the creation of the dataset failed, throw an exception
+ if( dataset_id <= 0 )
throwException("createDataSet", "H5Dcreate failed");
- }
+
+ // No failure, create and return the DataSet object
+ DataSet dataset( dataset_id );
+ return( dataset );
}
// Opens an existing dataset at this location.
@@ -120,16 +115,15 @@ DataSet CommonFG::openDataSet( const char* name ) const
// the location id and the dataset's name
hid_t dataset_id = H5Dopen( getLocId(), name );
- // If the dataset id is valid, create and return the DataSet object
- if( dataset_id > 0 )
- {
- DataSet dataset( dataset_id );
- return( dataset );
- }
- else
+ // If the dataset's opening failed, throw an exception
+ if( dataset_id <= 0 )
{
throwException("openDataSet", "H5Dopen failed");
}
+
+ // No failure, create and return the DataSet object
+ DataSet dataset( dataset_id );
+ return( dataset );
}
// Creates a link of the specified type from new_name to current_name;
@@ -291,13 +285,14 @@ hid_t CommonFG::p_openDataType( const char* name ) const
// giving either the file or group id
hid_t datatype_id = H5Topen( getLocId(), name );
- // If the datatype id is valid, return it, otherwise, throw an exception.
- if( datatype_id > 0 )
- return( datatype_id );
- else
+ // If the datatype's opening failed, throw an exception
+ if( datatype_id <= 0 )
{
throwException("openDataType", "H5Topen failed");
}
+
+ // No failure, return the datatype id
+ return( datatype_id );
}
//
@@ -379,12 +374,11 @@ int CommonFG::iterateElems( const string& name, int *idx, H5G_iterate_t op , voi
int CommonFG::iterateElems( const char* name, int *idx, H5G_iterate_t op , void* op_data )
{
int ret_value = H5Giterate( getLocId(), name, idx, op, op_data );
- if( ret_value >= 0 )
- return( ret_value );
- else // raise exception when H5Giterate returns a negative value
+ if( ret_value < 0 )
{
throwException("iterateElems", "H5Giterate failed");
}
+ return( ret_value );
}
CommonFG::CommonFG()
diff --git a/c++/src/H5DataSpace.h b/c++/src/H5DataSpace.h
index 67f4537..7267fe6 100644
--- a/c++/src/H5DataSpace.h
+++ b/c++/src/H5DataSpace.h
@@ -21,7 +21,7 @@ class DataSpace : public IdComponent {
void copy( const DataSpace& like_space ); // H5Scopy
// Assignment operator
- virtual DataSpace& operator=( const DataSpace& rhs );
+ DataSpace& operator=( const DataSpace& rhs );
// Determines if this dataspace is a simple one.
bool isSimple() const;
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index a7de20b..bef66f3 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -76,14 +76,6 @@ DataType& DataType::operator=( const DataType& rhs )
return(*this);
}
-// Makes a copy of the predefined type and stores the new
-// id in the left hand side object.
-DataType& DataType::operator=( const PredType& rhs )
-{
- copy(rhs);
- return(*this);
-}
-
// Determines whether two datatypes refer to the same actual datatype.
bool DataType::operator==(const DataType& compared_type ) const
{
@@ -108,7 +100,7 @@ bool DataType::operator==(const DataType& compared_type ) const
//{
//}
-// Creates a new variable-length datatype - Note: make it inheritance???
+// Creates a new variable-length datatype - Note: should use inheritance -
// work in progress
//DataType DataType::vlenCreate( const DataType& base_type )
//{
diff --git a/c++/src/H5DataType.h b/c++/src/H5DataType.h
index ebe7ded..0b9d877 100644
--- a/c++/src/H5DataType.h
+++ b/c++/src/H5DataType.h
@@ -42,11 +42,8 @@ class DataType : public H5Object {
// Returns a pointer to the current global overflow function.
H5T_overflow_t getOverflow(void) const;
- // Assignment operator that takes a predefined type
- virtual DataType& operator=( const PredType& rhs );
-
// Assignment operator
- virtual DataType& operator=( const DataType& rhs );
+ DataType& operator=( const DataType& rhs );
// Determines whether two datatypes are the same.
bool operator==(const DataType& compared_type ) const;
diff --git a/c++/src/H5IdComponent.h b/c++/src/H5IdComponent.h
index 31e9acd..09a227b 100644
--- a/c++/src/H5IdComponent.h
+++ b/c++/src/H5IdComponent.h
@@ -42,7 +42,7 @@ class IdComponent {
bool noReference();
// Assignment operator
- virtual IdComponent& operator=( const IdComponent& rhs );
+ IdComponent& operator=( const IdComponent& rhs );
// Resets this IdComponent instance
//template <class Type>
diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp
index d883ba5..885412c 100644
--- a/c++/src/H5PredType.cpp
+++ b/c++/src/H5PredType.cpp
@@ -29,9 +29,10 @@ PredType::PredType( const PredType& original ) : AtomType( original ) {}
// Makes a copy of the predefined type and stores the new
// id in the left hand side object.
-DataType& PredType::operator=( const PredType& rhs )
+PredType& PredType::operator=( const PredType& rhs )
{
- return(DataType::operator=(rhs));
+ copy(rhs);
+ return(*this);
}
const PredType PredType::NotAtexit; // only for atexit/global dest. problem
diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h
index eabb34a..8c0fbf0 100644
--- a/c++/src/H5PredType.h
+++ b/c++/src/H5PredType.h
@@ -227,7 +227,7 @@ class PredType : public AtomType {
// Makes a copy of the predefined type and stores the new
// id in the left hand side object.
- DataType& operator=( const PredType& rhs );
+ PredType& operator=( const PredType& rhs );
};
#ifndef H5_NO_NAMESPACE
}
diff --git a/c++/src/H5PropList.h b/c++/src/H5PropList.h
index 037b0d8..325f7f5 100644
--- a/c++/src/H5PropList.h
+++ b/c++/src/H5PropList.h
@@ -25,7 +25,7 @@ class PropList : public IdComponent {
void copy( const PropList& like_plist );
// Make a copy of the given property list using assignment statement
- virtual PropList& operator=( const PropList& rhs );
+ PropList& operator=( const PropList& rhs );
// Gets the class of this property list, i.e. H5P_FILE_CREATE,
// H5P_FILE_ACCESS, ...