From: Daniel Garcia-Sanchez Date: Mon, 29 Oct 2018 21:40:13 +0000 (+0100) Subject: Make herr_t ret local variable X-Git-Tag: v9.1.0-rc1~453^2~20 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fef0dfb9df0c0e9873b55fe281d2ea139537f9a1;p=dealii.git Make herr_t ret local variable --- diff --git a/include/deal.II/base/hdf5.h b/include/deal.II/base/hdf5.h index 2b0fd84bae..2f9baad0bf 100644 --- a/include/deal.II/base/hdf5.h +++ b/include/deal.II/base/hdf5.h @@ -375,20 +375,6 @@ namespace HDF5 * If true use parallel HDF5, if false use serial HDF5. */ const bool mpi; - - /** - * Return value of the last HDF5 C library call. - * - * The HDF5 calls return a non-negative value if successful; otherwise they - * return a negative value. - * - * Calls such as - * [H5DWrite](https://support.hdfgroup.org/HDF5/doc/RM/RM_H5D.html#Dataset-Write) - * use this variable to store the return value. Other calls such as - * [H5Pcreate](https://support.hdfgroup.org/HDF5/doc/RM/RM_H5P.html#Property-Create) - * don't use this variable to store the return value. - */ - herr_t ret; }; /** diff --git a/source/base/hdf5.cc b/source/base/hdf5.cc index 7d1a55b786..60287de5e1 100644 --- a/source/base/hdf5.cc +++ b/source/base/hdf5.cc @@ -429,6 +429,7 @@ namespace HDF5 const std::shared_ptr t_type = internal::get_hdf5_datatype(); T value; hid_t attr; + herr_t ret; attr = H5Aopen(*hdf5_reference, attr_name.data(), H5P_DEFAULT); @@ -437,6 +438,9 @@ namespace HDF5 Assert(ret >= 0, ExcMessage("Error at H5Aread")); ret = H5Aclose(attr); Assert(ret >= 0, ExcMessage("Error at H5Aclose")); + + // This avoids the unused warning + (void)ret; return value; } @@ -447,8 +451,10 @@ namespace HDF5 HDF5Object::get_attribute(const std::string &attr_name) { // The enum field generated by h5py can be casted to int - int int_value; - hid_t attr; + int int_value; + hid_t attr; + herr_t ret; + attr = H5Aopen(*hdf5_reference, attr_name.data(), H5P_DEFAULT); Assert(attr >= 0, ExcMessage("Error at H5Aopen")); ret = H5Aread(attr, H5T_NATIVE_INT, &int_value); @@ -457,6 +463,8 @@ namespace HDF5 Assert(ret >= 0, ExcMessage("Error at H5Aclose")); // The int can be casted to a bool bool bool_value = (bool)int_value; + + (void)ret; return bool_value; } @@ -478,9 +486,10 @@ namespace HDF5 // Todo: // - Use H5Dvlen_reclaim instead of free - char *string_out; - hid_t attr; - hid_t type; + char * string_out; + hid_t attr; + hid_t type; + herr_t ret; /* Create a datatype to refer to. */ type = H5Tcopy(H5T_C_S1); @@ -505,6 +514,8 @@ namespace HDF5 free(string_out); H5Tclose(type); H5Aclose(attr); + + (void)ret; return string_value; } @@ -514,8 +525,10 @@ namespace HDF5 void HDF5Object::set_attribute(const std::string &attr_name, const T value) { - hid_t attr; - hid_t aid; + hid_t attr; + hid_t aid; + herr_t ret; + const std::shared_ptr t_type = internal::get_hdf5_datatype(); @@ -542,6 +555,8 @@ namespace HDF5 Assert(ret >= 0, ExcMessage("Error at H5Sclose")); ret = H5Aclose(attr); Assert(ret >= 0, ExcMessage("Error at H5Aclose")); + + (void)ret; } @@ -560,9 +575,10 @@ namespace HDF5 // (char *). For this reason the std::string value has been copied to a C // string. - hid_t attr; - hid_t aid; - hid_t t_type; + hid_t attr; + hid_t aid; + hid_t t_type; + herr_t ret; // Reserve space for the string and the null terminator char *c_string_value = (char *)malloc(sizeof(char) * (value.size() + 1)); @@ -599,6 +615,8 @@ namespace HDF5 Assert(ret >= 0, ExcMessage("Error at H5Sclose")); ret = H5Aclose(attr); Assert(ret >= 0, ExcMessage("Error at H5Aclose")); + + (void)ret; } @@ -702,7 +720,8 @@ namespace HDF5 { const std::shared_ptr t_type = internal::get_hdf5_datatype(); - hid_t plist; + hid_t plist; + herr_t ret; Container data = internal::initialize_container(dimensions); @@ -741,6 +760,7 @@ namespace HDF5 Assert(ret >= 0, ExcInternalError()); } + (void)ret; return data; } @@ -756,6 +776,7 @@ namespace HDF5 const std::shared_ptr t_type = internal::get_hdf5_datatype(); hid_t plist; hid_t memory_dataspace; + herr_t ret; std::vector data_dimensions{ static_cast(coordinates.size() / rank)}; @@ -810,6 +831,7 @@ namespace HDF5 ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5SClose")); + (void)ret; return data; } @@ -822,8 +844,9 @@ namespace HDF5 { const std::shared_ptr t_type = internal::get_hdf5_datatype(); - hid_t plist; - hid_t memory_dataspace; + hid_t plist; + hid_t memory_dataspace; + herr_t ret; // In this particular overload of read_hyperslab the data_dimensions are // the same as count @@ -877,6 +900,7 @@ namespace HDF5 ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5SClose")); + (void)ret; return data; } @@ -892,8 +916,9 @@ namespace HDF5 { const std::shared_ptr t_type = internal::get_hdf5_datatype(); - hid_t plist; - hid_t memory_dataspace; + hid_t plist; + hid_t memory_dataspace; + herr_t ret; Container data = internal::initialize_container(data_dimensions); @@ -947,6 +972,7 @@ namespace HDF5 ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5SClose")); + (void)ret; return data; } @@ -959,8 +985,9 @@ namespace HDF5 const std::shared_ptr t_type = internal::get_hdf5_datatype(); const std::vector data_dimensions = {0}; - hid_t memory_dataspace; - hid_t plist; + hid_t memory_dataspace; + hid_t plist; + herr_t ret; memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL); Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple")); @@ -1004,6 +1031,8 @@ namespace HDF5 ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5SClose")); + + (void)ret; } @@ -1015,7 +1044,8 @@ namespace HDF5 AssertDimension(size, internal::get_container_size(data)); const std::shared_ptr t_type = internal::get_hdf5_datatype(); - hid_t plist; + hid_t plist; + herr_t ret; if (mpi) { @@ -1051,6 +1081,8 @@ namespace HDF5 ret = H5Pclose(plist); Assert(ret >= 0, ExcMessage("Error at H5Pclose")); } + + (void)ret; } @@ -1064,8 +1096,9 @@ namespace HDF5 const std::shared_ptr t_type = internal::get_hdf5_datatype(); const std::vector data_dimensions = {data.size()}; - hid_t memory_dataspace; - hid_t plist; + hid_t memory_dataspace; + hid_t plist; + herr_t ret; memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL); @@ -1113,6 +1146,8 @@ namespace HDF5 } ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5SClose")); + + (void)ret; } @@ -1134,8 +1169,9 @@ namespace HDF5 // the same as count const std::vector data_dimensions = count; - hid_t memory_dataspace; - hid_t plist; + hid_t memory_dataspace; + hid_t plist; + herr_t ret; memory_dataspace = H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL); @@ -1180,6 +1216,8 @@ namespace HDF5 } ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5Sclose")); + + (void)ret; } @@ -1196,8 +1234,9 @@ namespace HDF5 const std::shared_ptr t_type = internal::get_hdf5_datatype(); - hid_t memory_dataspace; - hid_t plist; + hid_t memory_dataspace; + hid_t plist; + herr_t ret; memory_dataspace = H5Screate_simple(data_dimensions.size(), data_dimensions.data(), NULL); @@ -1246,6 +1285,8 @@ namespace HDF5 } ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5Sclose")); + + (void)ret; } @@ -1257,8 +1298,9 @@ namespace HDF5 std::shared_ptr t_type = internal::get_hdf5_datatype(); std::vector data_dimensions = {0}; - hid_t memory_dataspace; - hid_t plist; + hid_t memory_dataspace; + hid_t plist; + herr_t ret; memory_dataspace = H5Screate_simple(1, data_dimensions.data(), NULL); Assert(memory_dataspace >= 0, ExcMessage("Error at H5Screate_simple")); @@ -1298,6 +1340,8 @@ namespace HDF5 } ret = H5Sclose(memory_dataspace); Assert(ret >= 0, ExcMessage("Error at H5Sclose")); + + (void)ret; } @@ -1532,6 +1576,7 @@ namespace HDF5 }); hid_t plist; + herr_t ret; const MPI_Info info = MPI_INFO_NULL; if (mpi) @@ -1574,6 +1619,8 @@ namespace HDF5 ret = H5Pclose(plist); Assert(ret >= 0, ExcMessage("Error at H5Pclose")); } + + (void)ret; }