summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBinh-Minh Ribler <bmribler@hdfgroup.org>2016-04-22 18:58:08 (GMT)
committerBinh-Minh Ribler <bmribler@hdfgroup.org>2016-04-22 18:58:08 (GMT)
commit58803d08320c0f704bc4cca600e9701572ddc1b4 (patch)
tree54f45208d66d18442fd5c588e4a676b3a203a072
parent38687f3498d0878c1c28cb52b8b9e070fcb45da8 (diff)
downloadhdf5-58803d08320c0f704bc4cca600e9701572ddc1b4.zip
hdf5-58803d08320c0f704bc4cca600e9701572ddc1b4.tar.gz
hdf5-58803d08320c0f704bc4cca600e9701572ddc1b4.tar.bz2
[svn-r29765] Purpose: Code cleanup
Description: - Removed many warnings: warning: use of old-style cast warning: enumeration value ‘H5D_VIRTUAL’ not handled in switch warning: comparison between signed and unsigned There are others of the same warnings and they will be taken care of in the next release. - Made some code reuse between overloads Merged from trunk r29340. Platforms tested: Linux/32 2.6 (jam) Linux/64 (platypus) Darwin (osx1010test)
-rw-r--r--c++/src/H5ArrayType.cpp5
-rw-r--r--c++/src/H5Attribute.cpp2
-rw-r--r--c++/src/H5CommonFG.cpp107
-rw-r--r--c++/src/H5DataType.cpp6
-rw-r--r--c++/src/H5Location.cpp8
-rw-r--r--c++/src/H5Object.cpp2
-rw-r--r--c++/src/H5PropList.cpp2
-rw-r--r--c++/test/h5cpputil.cpp4
8 files changed, 53 insertions, 83 deletions
diff --git a/c++/src/H5ArrayType.cpp b/c++/src/H5ArrayType.cpp
index 5792467..9731a13 100644
--- a/c++/src/H5ArrayType.cpp
+++ b/c++/src/H5ArrayType.cpp
@@ -54,11 +54,8 @@ ArrayType::ArrayType( const hid_t existing_id ) : DataType( existing_id )
///\brief Copy constructor: makes a copy of the original ArrayType object.
// Programmer Binh-Minh Ribler - May 2004
//--------------------------------------------------------------------------
-ArrayType::ArrayType( const ArrayType& original ) : DataType( original )
+ArrayType::ArrayType( const ArrayType& original ) : DataType( original ), rank(original.rank)
{
- // Copy the rank of the original array
- rank = original.rank;
-
// Allocate space then copy the dimensions from the original array
dimensions = new hsize_t[rank];
for (int i = 0; i < rank; i++)
diff --git a/c++/src/H5Attribute.cpp b/c++/src/H5Attribute.cpp
index 0f5bf4b..bf45fe4 100644
--- a/c++/src/H5Attribute.cpp
+++ b/c++/src/H5Attribute.cpp
@@ -567,7 +567,7 @@ void Attribute::p_read_fixed_len(const DataType& mem_type, H5std_string& strg) c
// If there is data, allocate buffer and read it.
if (attr_size > 0)
{
- char *strg_C = new char[(size_t)attr_size+1];
+ char *strg_C = new char[attr_size+1];
herr_t ret_value = H5Aread(id, mem_type.getId(), strg_C);
if( ret_value < 0 )
{
diff --git a/c++/src/H5CommonFG.cpp b/c++/src/H5CommonFG.cpp
index a18637b..789abc9 100644
--- a/c++/src/H5CommonFG.cpp
+++ b/c++/src/H5CommonFG.cpp
@@ -67,21 +67,21 @@ namespace H5 {
/// then a default size is chosen.
// Programmer Binh-Minh Ribler - 2000
//--------------------------------------------------------------------------
-Group CommonFG::createGroup( const char* name, size_t size_hint ) const
+ Group CommonFG::createGroup( const char* name, size_t size_hint ) const
{
- // Group creation property list for size_hint
- hid_t gcpl_id = 0;
-
- // Set the local heap size hint
- if(!(size_hint == (size_t)-1 || size_hint == 0)) {
+ // Group creation property list for size hint
+ hid_t gcpl_id = 0;
+ // Set the local heap size hint
+ if (size_hint > 0)
+ {
// If the creation of the property list failed, throw an exception
- if((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
throwException("createGroup", "H5Pcreate failed");
- if( H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) {
+ if (H5Pset_local_heap_size_hint(gcpl_id, size_hint) < 0) {
H5Pclose(gcpl_id);
- throwException("createGroup", "H5Pset_local_heap_size failed");
+ throwException("createGroup", "H5Pset_local_heap_size_hint failed");
}
}
@@ -268,6 +268,9 @@ void CommonFG::link( H5L_type_t link_type, const char* curr_name, const char* ne
ret_value = H5Lcreate_soft( curr_name, getLocId(), new_name, H5P_DEFAULT, H5P_DEFAULT );
break;
+ case H5L_TYPE_ERROR:
+ case H5L_TYPE_EXTERNAL:
+ case H5L_TYPE_MAX:
default:
throwException("link", "unknown link type");
break;
@@ -478,6 +481,8 @@ H5std_string CommonFG::getLinkval( const H5std_string& name, size_t size ) const
///\param plist - IN: Property list to use
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - 2014 (original 2000)
+// Modification
+// Replaced the version without const parameter - Apr, 2014
//--------------------------------------------------------------------------
void CommonFG::mount(const char* name, const H5File& child, const PropList& plist ) const
{
@@ -495,28 +500,11 @@ void CommonFG::mount(const char* name, const H5File& child, const PropList& plis
//--------------------------------------------------------------------------
// Function: CommonFG::mount
-// Purpose This is an overloaded member function, kept for backward
-// compatibility. It differs from the above function in that it
-// misses const's. This wrapper will be removed in future release.
-// Param name - IN: Name of the group
-// Param child - IN: File to mount
-// Param plist - IN: Property list to use
-// Exception H5::FileIException or H5::GroupIException
-// Programmer Binh-Minh Ribler - 2000
-// Modification
-// Modified to call its replacement. -BMR, 2014/04/16
-// Removed from documentation. -BMR, 2016/03/07
-//--------------------------------------------------------------------------
-void CommonFG::mount(const char* name, H5File& child, PropList& plist) const
-{
- mount(name, (const H5File)child, (const PropList)plist);
-}
-
-//--------------------------------------------------------------------------
-// Function: CommonFG::mount
///\brief This is an overloaded member function, provided for convenience.
/// It takes an \c H5std_string for \a name.
// Programmer Binh-Minh Ribler - 2000
+// Modification
+// Replaced the version without const parameter - Apr, 2014
//--------------------------------------------------------------------------
void CommonFG::mount(const H5std_string& name, const H5File& child, const PropList& plist) const
{
@@ -524,21 +512,6 @@ void CommonFG::mount(const H5std_string& name, const H5File& child, const PropLi
}
//--------------------------------------------------------------------------
-// Function: CommonFG::mount
-// Purpose This is an overloaded member function, kept for backward
-// compatibility. It differs from the above function in that it
-// misses const's. This wrapper will be removed in future release.
-// Programmer Binh-Minh Ribler - 2014
-// Modification
-// Modified to call its replacement. -BMR, 2014/04/16
-// Removed from documentation. -BMR, 2016/03/07
-//--------------------------------------------------------------------------
-void CommonFG::mount(const H5std_string& name, H5File& child, PropList& plist) const
-{
- mount(name.c_str(), (const H5File)child, (const PropList)plist);
-}
-
-//--------------------------------------------------------------------------
// Function: CommonFG::unmount
///\brief Unmounts the specified file.
///\param name - IN: Name of the file to unmount
@@ -1039,6 +1012,8 @@ H5O_type_t CommonFG::childObjType(const char* objname) const
case H5O_TYPE_NAMED_DATATYPE:
objtype = objinfo.type;
break;
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
default:
throwException("childObjType", "Unknown type of object");
}
@@ -1112,6 +1087,8 @@ H5O_type_t CommonFG::childObjType(hsize_t index, H5_index_t index_type, H5_iter_
case H5O_TYPE_NAMED_DATATYPE:
objtype = objinfo.type;
break;
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
default:
throwException("childObjType", "Unknown type of object");
}
@@ -1200,21 +1177,13 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx) const
///\return Object type
///\exception H5::FileIException or H5::GroupIException
// Programmer Binh-Minh Ribler - May, 2010
+// Modification
+// Modified to use the other function. -BMR, 2016/03/07
//--------------------------------------------------------------------------
H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, char* type_name) const
{
- H5G_obj_t obj_type = H5Gget_objtype_by_idx(getLocId(), idx);
- switch (obj_type)
- {
- case H5G_LINK: HDstrcpy(type_name, "symbolic link"); break;
- case H5G_GROUP: HDstrcpy(type_name, "group"); break;
- case H5G_DATASET: HDstrcpy(type_name, "dataset"); break;
- case H5G_TYPE: HDstrcpy(type_name, "datatype"); break;
- case H5G_UNKNOWN:
- default:
- throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed");
- }
- return (obj_type);
+ H5std_string stype_name(type_name);
+ return(getObjTypeByIdx(idx, stype_name));
}
//--------------------------------------------------------------------------
// Function: CommonFG::getObjTypeByIdx
@@ -1229,18 +1198,22 @@ H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, char* type_name) const
//--------------------------------------------------------------------------
H5G_obj_t CommonFG::getObjTypeByIdx(hsize_t idx, H5std_string& type_name) const
{
- H5G_obj_t obj_type = H5Gget_objtype_by_idx(getLocId(), idx);
- switch (obj_type)
- {
- case H5G_LINK: type_name = H5std_string("symbolic link"); break;
- case H5G_GROUP: type_name = H5std_string("group"); break;
- case H5G_DATASET: type_name = H5std_string("dataset"); break;
- case H5G_TYPE: type_name = H5std_string("datatype"); break;
- case H5G_UNKNOWN:
- default:
- throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed");
- }
- return (obj_type);
+ H5G_obj_t obj_type = H5Gget_objtype_by_idx(getLocId(), idx);
+ switch (obj_type)
+ {
+ case H5G_LINK: type_name = H5std_string("symbolic link"); break;
+ case H5G_GROUP: type_name = H5std_string("group"); break;
+ case H5G_DATASET: type_name = H5std_string("dataset"); break;
+ case H5G_TYPE: type_name = H5std_string("datatype"); break;
+ case H5G_UNKNOWN:
+ case H5G_UDLINK:
+ case H5G_RESERVED_5:
+ case H5G_RESERVED_6:
+ case H5G_RESERVED_7:
+ default:
+ throwException("getObjTypeByIdx", "H5Gget_objtype_by_idx failed");
+ }
+ return (obj_type);
}
#endif // DOXYGEN_SHOULD_SKIP_THIS
diff --git a/c++/src/H5DataType.cpp b/c++/src/H5DataType.cpp
index 3b5d05b..08b317e 100644
--- a/c++/src/H5DataType.cpp
+++ b/c++/src/H5DataType.cpp
@@ -360,10 +360,10 @@ void DataType::commit(H5Location& loc, const H5std_string& name)
bool DataType::committed() const
{
// Call C function to determine if a datatype is a named one
- htri_t committed = H5Tcommitted( id );
- if( committed > 0 )
+ htri_t is_committed = H5Tcommitted( id );
+ if (is_committed > 0)
return true;
- else if( committed == 0 )
+ else if (is_committed == 0)
return false;
else
{
diff --git a/c++/src/H5Location.cpp b/c++/src/H5Location.cpp
index 66901f7..56ed178 100644
--- a/c++/src/H5Location.cpp
+++ b/c++/src/H5Location.cpp
@@ -190,7 +190,7 @@ Attribute H5Location::openAttribute( const H5std_string& name ) const
Attribute H5Location::openAttribute( const unsigned int idx ) const
{
hid_t attr_id = H5Aopen_by_idx(getId(), ".", H5_INDEX_CRT_ORDER,
- H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_DEFAULT);
+ H5_ITER_INC, static_cast<hsize_t>(idx), H5P_DEFAULT, H5P_DEFAULT);
if( attr_id > 0 )
{
Attribute attr;
@@ -240,7 +240,7 @@ int H5Location::iterateAttrs( attr_operator_t user_op, unsigned *_idx, void *op_
if( ret_value >= 0 ) {
/* Pass back update index value to calling code */
if (_idx)
- *_idx = (unsigned)idx;
+ *_idx = static_cast<unsigned>(idx);
return( ret_value );
}
@@ -262,7 +262,7 @@ int H5Location::getNumAttrs() const
if(H5Oget_info(getId(), &oinfo) < 0)
throw AttributeIException(inMemFunc("getNumAttrs"), "H5Oget_info failed");
else
- return( (int)oinfo.num_attrs );
+ return(static_cast<int>(oinfo.num_attrs));
}
//--------------------------------------------------------------------------
@@ -517,7 +517,7 @@ ssize_t H5Location::getComment(const char* name, size_t buf_size, char* comment)
}
// If the comment is longer than the provided buffer size, the C library
// will not null terminate it
- if ((size_t)comment_len >= buf_size)
+ if (static_cast<size_t>(comment_len) >= buf_size)
comment[buf_size-1] = '\0';
// Return the actual comment length, which might be different from buf_size
diff --git a/c++/src/H5Object.cpp b/c++/src/H5Object.cpp
index 35e34b5..3cce9fe 100644
--- a/c++/src/H5Object.cpp
+++ b/c++/src/H5Object.cpp
@@ -109,7 +109,7 @@ H5std_string H5Object::getObjName() const
H5std_string obj_name(""); // object name to return
// Preliminary call to get the size of the object name
- ssize_t name_size = H5Iget_name(getId(), NULL, (size_t)0);
+ ssize_t name_size = H5Iget_name(getId(), NULL, static_cast<size_t>(0));
// If H5Iget_name failed, throw exception
if (name_size < 0)
diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp
index 81bb023..b954191 100644
--- a/c++/src/H5PropList.cpp
+++ b/c++/src/H5PropList.cpp
@@ -592,7 +592,7 @@ void PropList::setProperty(const char* name, void* value) const
//--------------------------------------------------------------------------
void PropList::setProperty(const char* name, const char* charptr) const
{
- herr_t ret_value = H5Pset(id, name, (void*) charptr);
+ herr_t ret_value = H5Pset(id, name, (void*)charptr);
if (ret_value < 0)
{
throw PropListIException(inMemFunc("setProperty"), "H5Pset failed");
diff --git a/c++/test/h5cpputil.cpp b/c++/test/h5cpputil.cpp
index 40e81cc..7ad7364 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 <<