summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff_attr.c4
-rw-r--r--tools/lib/h5diff_dset.c108
-rw-r--r--tools/lib/h5tools_filters.c202
3 files changed, 149 insertions, 165 deletions
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index 74607da..9bebcbe 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -472,8 +472,8 @@ hsize_t diff_attr(hid_t loc1_id,
for(j = 0; j < rank1; j++)
nelmts1 *= dims1[j];
- buf1 = (void *)HDmalloc((size_t)(nelmts1 * msize1));
- buf2 = (void *)HDmalloc((size_t)(nelmts1 * msize2));
+ buf1 = (void *)HDcalloc((size_t)(nelmts1), msize1);
+ buf2 = (void *)HDcalloc((size_t)(nelmts1), msize2);
if(buf1 == NULL || buf2 == NULL) {
parallel_print("cannot read into memory\n");
goto error;
diff --git a/tools/lib/h5diff_dset.c b/tools/lib/h5diff_dset.c
index a4f7863..998a8ca 100644
--- a/tools/lib/h5diff_dset.c
+++ b/tools/lib/h5diff_dset.c
@@ -170,6 +170,7 @@ hsize_t diff_datasetid( hid_t did1,
const char *obj2_name,
diff_opt_t *options)
{
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t sid1=-1;
hid_t sid2=-1;
hid_t f_tid1=-1;
@@ -211,30 +212,31 @@ hsize_t diff_datasetid( hid_t did1,
int i;
unsigned int vl_data = 0; /*contains VL datatypes */
+ options->err_stat = 1;
h5difftrace("diff_datasetid start\n");
/* Get the dataspace handle */
if((sid1 = H5Dget_space(did1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank1 = H5Sget_simple_extent_ndims(sid1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get the dataspace handle */
if((sid2 = H5Dget_space(did2)) < 0 )
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
/* Get rank */
if((rank2 = H5Sget_simple_extent_ndims(sid2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid1, dims1, maxdim1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
/* Get dimensions */
if(H5Sget_simple_extent_dims(sid2, dims2, maxdim2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_dims failed");
h5diffdebug3("rank: %ld - %ld\n", rank1, rank2);
/*-------------------------------------------------------------------------
@@ -244,25 +246,25 @@ hsize_t diff_datasetid( hid_t did1,
/* Get the data type */
if((f_tid1 = H5Dget_type(did1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/* Get the data type */
if((f_tid2 = H5Dget_type(did2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* get the storage layout type
*-------------------------------------------------------------------------
*/
if((dcpl1 = H5Dget_create_plist(did1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(did2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((stl1 = H5Pget_layout(dcpl1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
if((stl2 = H5Pget_layout(dcpl2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_layout failed");
/*-------------------------------------------------------------------------
* check for empty datasets
@@ -303,10 +305,10 @@ hsize_t diff_datasetid( hid_t did1,
*/
h5difftrace("check for memory type and sizes\n");
if((m_tid1 = H5Tget_native_type(f_tid1, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
if((m_tid2 = H5Tget_native_type(f_tid2, H5T_DIR_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tget_native_type failed");
m_size1 = H5Tget_size(m_tid1);
m_size2 = H5Tget_size(m_tid2);
@@ -368,14 +370,14 @@ hsize_t diff_datasetid( hid_t did1,
if (FAIL == match_up_memsize (f_tid1, f_tid2,
&m_tid1, &m_tid2,
&m_size1, &m_size2))
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "match_up_memsize failed");
h5diffdebug3("m_size: %ld - %ld\n", m_size1, m_size2);
dadims = dims1;
dam_size = m_size1;
dam_tid = m_tid1;
danelmts = nelmts1;
need = (size_t)(nelmts1 * m_size1); /* bytes needed */
- }
+ }
else {
h5diffdebug3("Array dims: %d - %d\n", dims1[0], dims2[0]);
/* Compare the smallest array, but create the largest buffer */
@@ -399,6 +401,7 @@ hsize_t diff_datasetid( hid_t did1,
name1 = diff_basename(obj1_name);
if(obj2_name)
name2 = diff_basename(obj2_name);
+ h5diffdebug3("obj_names: %s - %s\n", name1, name2);
/*----------------------------------------------------------------
@@ -413,20 +416,30 @@ hsize_t diff_datasetid( hid_t did1,
if(buf1 != NULL && buf2 != NULL) {
h5difftrace("buf1 != NULL && buf2 != NULL\n");
if(H5Dread(did1, m_tid1, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
h5difftrace("H5Dread did2\n");
if(H5Dread(did2, m_tid2, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* array diff */
nfound = diff_array(buf1, buf2, danelmts, (hsize_t)0, rank1, dadims,
options, name1, name2, dam_tid, did1, did2);
+ h5diffdebug2("diff_array nfound:%d\n", nfound);
/* reclaim any VL memory, if necessary */
if(vl_data) {
+ h5difftrace("check vl_data\n");
H5Dvlen_reclaim(m_tid1, sid1, H5P_DEFAULT, buf1);
H5Dvlen_reclaim(m_tid2, sid2, H5P_DEFAULT, buf2);
} /* end if */
+ if(buf1 != NULL) {
+ HDfree(buf1);
+ buf1 = NULL;
+ }
+ if(buf2 != NULL) {
+ HDfree(buf2);
+ buf2 = NULL;
+ }
} /* end if */
else { /* possibly not enough memory, read/compare by hyperslabs */
size_t p_type_nbytes = dam_size; /*size of memory type */
@@ -469,9 +482,9 @@ hsize_t diff_datasetid( hid_t did1,
* E.g., sm_space.
*/
if((sm_buf1 = HDmalloc((size_t)sm_nbytes)) == NULL)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
if((sm_buf2 = HDmalloc((size_t)sm_nbytes)) == NULL)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "HDmalloc failed");
sm_nelmts = sm_nbytes / p_type_nbytes;
sm_space = H5Screate_simple(1, &sm_nelmts, NULL);
@@ -488,19 +501,19 @@ hsize_t diff_datasetid( hid_t did1,
hs_nelmts *= hs_size[i];
} /* end for */
if(H5Sselect_hyperslab(sid1, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sid2, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
if(H5Sselect_hyperslab(sm_space, H5S_SELECT_SET, zero, NULL, &hs_nelmts, NULL) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sselect_hyperslab failed");
} /* end if */
else
hs_nelmts = 1;
if(H5Dread(did1, m_tid1, sm_space, sid1, H5P_DEFAULT, sm_buf1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
if(H5Dread(did2, m_tid2, sm_space, sid2, H5P_DEFAULT, sm_buf2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dread failed");
/* get array differences. in the case of hyperslab read, increment the number of differences
found in each hyperslab and pass the position at the beginning for printing */
@@ -522,6 +535,14 @@ hsize_t diff_datasetid( hid_t did1,
carry = 0;
} /* i */
} /* elmtno */
+ if(sm_buf1 != NULL) {
+ HDfree(sm_buf1);
+ sm_buf1 = NULL;
+ }
+ if(sm_buf2 != NULL) {
+ HDfree(sm_buf2);
+ sm_buf2 = NULL;
+ }
H5Sclose(sm_space);
} /* hyperslab read */
@@ -532,40 +553,11 @@ hsize_t diff_datasetid( hid_t did1,
* close
*-------------------------------------------------------------------------
*/
- h5difftrace("compare attributes?\n");
-
- /* free */
- if(buf1 != NULL) {
- HDfree(buf1);
- buf1 = NULL;
- } /* end if */
- if(buf2 != NULL) {
- HDfree(buf2);
- buf2 = NULL;
- } /* end if */
- if(sm_buf1 != NULL) {
- HDfree(sm_buf1);
- sm_buf1 = NULL;
- } /* end if */
- if(sm_buf2 != NULL) {
- HDfree(sm_buf2);
- sm_buf2 = NULL;
- } /* end if */
+ h5difftrace("reclaim any VL memory\n");
- H5E_BEGIN_TRY {
- H5Sclose(sid1);
- H5Sclose(sid2);
- H5Tclose(f_tid1);
- H5Tclose(f_tid2);
- H5Tclose(m_tid1);
- H5Tclose(m_tid2);
- } H5E_END_TRY;
- h5difftrace("diff_datasetid finish\n");
-
- return nfound;
+done:
-error:
- options->err_stat=1;
+ options->err_stat = ret_value;
/* free */
if(buf1 != NULL) {
@@ -607,7 +599,7 @@ error:
H5Tclose(m_tid2);
/* enable error reporting */
} H5E_END_TRY;
- h5difftrace("diff_datasetid errored\n");
+ h5diffdebug3("diff_datasetid return:%d with nfound:%d\n", ret_value, nfound);
return nfound;
}
diff --git a/tools/lib/h5tools_filters.c b/tools/lib/h5tools_filters.c
index 6ee58c5..abd55db 100644
--- a/tools/lib/h5tools_filters.c
+++ b/tools/lib/h5tools_filters.c
@@ -20,9 +20,9 @@
*/
static void print_warning(const char *dname, const char *fname)
{
- fprintf(stderr,
- "warning: dataset <%s> cannot be read, %s filter is not available\n",
- dname, fname);
+ fprintf(stderr,
+ "warning: dataset <%s> cannot be read, %s filter is not available\n",
+ dname, fname);
}
/*-------------------------------------------------------------------------
@@ -34,100 +34,97 @@ static void print_warning(const char *dname, const char *fname)
* 2) the internal filters might be turned off
*
* Return: 1, can read, 0, cannot, -1 error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: March 1, 2004
- *
*-------------------------------------------------------------------------
*/
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 nfilters; /* number of filters */
+ H5Z_filter_t filtn; /* filter identification number */
+ int i; /* index */
+ int udfilter_avail; /* index */
+
+ /* get information about filters */
+ if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_nfilters failed");
+
+ /* if we do not have filters, we can read the dataset safely */
+ if (!nfilters)
+ HGOTO_DONE(1);
+
+ /* check availability of filters */
+ for (i = 0; i < nfilters; i++) {
+ if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0)
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_filter2 failed");
+
+ switch (filtn) {
+ /*-------------------------------------------------------------------------
+ * user defined filter
+ *-------------------------------------------------------------------------
+ */
+ default:
+ if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0) {
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Zfilter_avail failed");
+ }
+ else if (!udfilter_avail) {
+ if (name)
+ print_warning(name, "user defined");
+ ret_value = 0;
+ }
+ break;
- int nfilters; /* number of filters */
- H5Z_filter_t filtn; /* filter identification number */
- int i; /* index */
- int udfilter_avail; /* index */
-
- /* get information about filters */
- if ((nfilters = H5Pget_nfilters(dcpl_id)) < 0)
- return -1;
-
- /* if we do not have filters, we can read the dataset safely */
- if (!nfilters)
- return 1;
-
- /* check availability of filters */
- for (i = 0; i < nfilters; i++) {
- if ((filtn = H5Pget_filter2(dcpl_id, (unsigned) i, 0, 0, 0, (size_t) 0, 0, NULL)) < 0)
- return -1;
-
- switch (filtn) {
- /*-------------------------------------------------------------------------
- * user defined filter
- *-------------------------------------------------------------------------
- */
- default:
- if ((udfilter_avail = H5Zfilter_avail(filtn)) < 0)
- return -1;
- else if (udfilter_avail == 0) {
- if (name)
- print_warning(name, "user defined");
- return 0;
- }
- break;
-
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_DEFLATE 1 , deflation like gzip
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_DEFLATE:
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_DEFLATE 1 , deflation like gzip
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
- if (name)
- print_warning(name,"deflate");
- return 0;
+ if (name)
+ print_warning(name,"deflate");
+ ret_value = 0;
#endif
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SZIP 4 , szip compression
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SZIP:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SZIP 4 , szip compression
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
- if (name)
- print_warning(name,"SZIP");
- return 0;
+ if (name)
+ print_warning(name,"SZIP");
+ ret_value = 0;
#endif
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SHUFFLE 2 , shuffle the data
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SHUFFLE:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_FLETCHER32:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_NBIT
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_NBIT:
- break;
- /*-------------------------------------------------------------------------
- * H5Z_FILTER_SCALEOFFSET
- *-------------------------------------------------------------------------
- */
- case H5Z_FILTER_SCALEOFFSET:
- break;
- }/*switch*/
- }/*for*/
-
- return 1;
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SHUFFLE 2 , shuffle the data
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SHUFFLE:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_FLETCHER32 3 , fletcher32 checksum of EDC
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_FLETCHER32:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_NBIT
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_NBIT:
+ break;
+ /*-------------------------------------------------------------------------
+ * H5Z_FILTER_SCALEOFFSET
+ *-------------------------------------------------------------------------
+ */
+ case H5Z_FILTER_SCALEOFFSET:
+ break;
+ }/*switch*/
+ }/*for*/
+
+done:
+ return ret_value;
}
/*-------------------------------------------------------------------------
@@ -138,31 +135,26 @@ int h5tools_canreadf(const char* name, /* object name, serves also as boolean pr
* except SZIP, which may be configured decoder-only.
*
* Return: 1, can write, 0, cannot, -1 error
- *
- * Programmer:
- *
- * Date: October 5, 2004
- *
*-------------------------------------------------------------------------
*/
H5_ATTR_CONST int
h5tools_can_encode(H5Z_filter_t filtn) {
switch (filtn) {
- /* user defined filter */
- default:
+ /* user defined filter */
+ default:
return 0;
- case H5Z_FILTER_DEFLATE:
+ case H5Z_FILTER_DEFLATE:
#ifndef H5_HAVE_FILTER_DEFLATE
return 0;
#endif
break;
- case H5Z_FILTER_SZIP:
+ case H5Z_FILTER_SZIP:
#ifndef H5_HAVE_FILTER_SZIP
return 0;
#else
- {
+ {
unsigned int filter_config_flags;
if (H5Zget_filter_info(filtn, &filter_config_flags) < 0)
@@ -171,36 +163,36 @@ h5tools_can_encode(H5Z_filter_t filtn) {
& (H5Z_FILTER_CONFIG_ENCODE_ENABLED | H5Z_FILTER_CONFIG_DECODE_ENABLED)) == 0) {
/* filter present but neither encode nor decode is supported (???) */
return -1;
- }
+ }
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;
- }
+ }
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;
- }
+ }
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;
}
- }
+ }
#endif
break;
- case H5Z_FILTER_SHUFFLE:
+ case H5Z_FILTER_SHUFFLE:
break;
- case H5Z_FILTER_FLETCHER32:
+ case H5Z_FILTER_FLETCHER32:
break;
- case H5Z_FILTER_NBIT:
+ case H5Z_FILTER_NBIT:
break;
- case H5Z_FILTER_SCALEOFFSET:
+ case H5Z_FILTER_SCALEOFFSET:
break;
}/*switch*/