summaryrefslogtreecommitdiffstats
path: root/tools/lib/h5tools_filters.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-10-13 21:34:01 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-10-13 21:34:01 (GMT)
commitd5c073d406f8d1e1ac3bcb05883bea406c8e9378 (patch)
treef9a8d818c032fa4d5f3cfa0857a799ecfa0cc9a7 /tools/lib/h5tools_filters.c
parentfc12672cdbd162f47293ec9ee2185e3efe1d0405 (diff)
downloadhdf5-d5c073d406f8d1e1ac3bcb05883bea406c8e9378.zip
hdf5-d5c073d406f8d1e1ac3bcb05883bea406c8e9378.tar.gz
hdf5-d5c073d406f8d1e1ac3bcb05883bea406c8e9378.tar.bz2
HDFFV-10296 Update tools lib to use the error handling macros.
Diffstat (limited to 'tools/lib/h5tools_filters.c')
-rw-r--r--tools/lib/h5tools_filters.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index abd55db..a5d0994 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -28,18 +28,22 @@ static void print_warning(const char *dname, const char *fname)
/*-------------------------------------------------------------------------
* Function: h5tools_canreadf
*
- * Purpose: check if the dataset creation property list has filters that
- * are not registered in the current configuration
- * 1) the external filters GZIP and SZIP might not be available
- * 2) the internal filters might be turned off
+ * Purpose: check if the dataset creation property list has filters that
+ * are not registered in the current configuration
+ * 1) the external filters GZIP and SZIP might not be available
+ * 2) the internal filters might be turned off
*
- * Return: 1, can read, 0, cannot, -1 error
+ * Return:
+ * 1 can read,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
-int h5tools_canreadf(const char* name, /* object name, serves also as boolean print */
+int
+h5tools_canreadf(const char* name, /* object name, serves also as boolean print */
hid_t dcpl_id) /* dataset creation property list */
{
- int ret_value = 1; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ int ret_value = 1;
int nfilters; /* number of filters */
H5Z_filter_t filtn; /* filter identification number */
int i; /* index */
@@ -130,56 +134,58 @@ done:
/*-------------------------------------------------------------------------
* Function: h5tools_canwritef
*
- * Purpose: check if the filter is available and can write data.
- * At this time, all filters that are available can write data,
- * except SZIP, which may be configured decoder-only.
+ * Purpose: check if the filter is available and can write data.
*
- * Return: 1, can write, 0, cannot, -1 error
+ * Return: 1 can write,
+ * 0 cannot,
+ * -1 error
*-------------------------------------------------------------------------
*/
H5_ATTR_CONST int
-h5tools_can_encode(H5Z_filter_t filtn) {
+h5tools_can_encode(H5Z_filter_t filtn)
+{
+ int ret_value = 1;
+
switch (filtn) {
/* user defined filter */
default:
- return 0;
-
+ HGOTO_DONE(0)
case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- return 0;
+ HGOTO_DONE(0)
#endif
break;
case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- return 0;
+ HGOTO_DONE(0)
#else
- {
+ {
unsigned int filter_config_flags;
if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zget_filter_info failed");
if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
/* filter present but neither encode nor decode is supported (???) */
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "neither encode nor decode is supported");
}
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_DECODE_ENABLED) {
/* decoder only: read but not write */
- return 0;
+ HGOTO_DONE(0)
}
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == H5Z_FILTER_CONFIG_ENCODE_ENABLED) {
/* encoder only: write but not read (???) */
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "encoder only: write but not read");
}
else if ((filter_config_flags
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED))
== (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) {
- return 1;
+ HGOTO_DONE(1)
}
- }
+ }
#endif
break;
@@ -196,6 +202,7 @@ h5tools_can_encode(H5Z_filter_t filtn) {
break;
}/*switch*/
- return 1;
+done:
+ return ret_value;
}