summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack/h5repack_verify.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-10-02 14:53:45 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-10-02 14:53:54 (GMT)
commit38e2f0e7847556ba06ee72e9451a1bab022c472e (patch)
treeed175ade604a36b87243b905d09183bef88f5fbf /tools/src/h5repack/h5repack_verify.c
parentb7e563266e8484c96d5ac75b9dcec2337bb15d43 (diff)
downloadhdf5-38e2f0e7847556ba06ee72e9451a1bab022c472e.zip
hdf5-38e2f0e7847556ba06ee72e9451a1bab022c472e.tar.gz
hdf5-38e2f0e7847556ba06ee72e9451a1bab022c472e.tar.bz2
Update error handling to support ARGS and tools stack
Diffstat (limited to 'tools/src/h5repack/h5repack_verify.c')
-rw-r--r--tools/src/h5repack/h5repack_verify.c177
1 files changed, 59 insertions, 118 deletions
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index 1a0dab7..e276b7b 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -33,11 +33,6 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil
* 1 match
* 0 do not match
* -1 error
- *
- * Programmer: Pedro Vicente, pvn@hdfgroup.org
- *
- * Date: December 19, 2003
- *
*-------------------------------------------------------------------------
*/
@@ -63,11 +58,10 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* open the output file */
if((fidout = H5Fopen(out_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
- return -1;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed on <%s>", out_fname);
- for(i = 0; i < options->op_tbl->nelems; i++)
- {
- char* name = options->op_tbl->objs[i].path;
+ for(i = 0; i < options->op_tbl->nelems; i++) {
+ char *name = options->op_tbl->objs[i].path;
pack_info_t *obj = &options->op_tbl->objs[i];
/*-------------------------------------------------------------------------
@@ -75,7 +69,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
if((sid = H5Dget_space(did)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
@@ -119,9 +113,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*-------------------------------------------------------------------------
*/
- if(options->all_filter == 1 || options->all_layout == 1)
- {
-
+ if(options->all_filter == 1 || options->all_layout == 1) {
/* Initialize indexing options */
h5trav_set_index(sort_by, sort_order);
/* init table */
@@ -131,19 +123,16 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
if(h5trav_gettable(fidout, travt) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
- for(i = 0; i < travt->nobjs; i++)
- {
+ for(i = 0; i < travt->nobjs; i++) {
char *name = travt->objs[i].name;
- if(travt->objs[i].type == H5TRAV_TYPE_DATASET)
- {
-
+ if(travt->objs[i].type == H5TRAV_TYPE_DATASET) {
/*-------------------------------------------------------------------------
* open
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on <%s>", name);
if((sid = H5Dget_space(did)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
@@ -155,8 +144,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* filter check
*-------------------------------------------------------------------------
*/
- if(options->all_filter == 1)
- {
+ if(options->all_filter == 1) {
if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
ok = 0;
}
@@ -165,8 +153,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* layout check
*-------------------------------------------------------------------------
*/
- if(options->all_layout == 1)
- {
+ if(options->all_layout == 1) {
pack_info_t pack;
init_packobject(&pack);
@@ -204,43 +191,37 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* open the input file */
if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0 )
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fopen failed on file <%s>", in_fname);
/* Get file creation property list for input file */
if((fcpl_in = H5Fget_create_plist(fidin)) < 0) {
- error_msg("failed to retrieve file creation property list\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
}
/* Get file space info for input file */
if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0) {
- error_msg("failed to retrieve file space strategy & threshold\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
}
/* Get file space page size for input file */
if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0) {
- error_msg("failed to retrieve file space page size\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space page size");
}
/* Output file is already opened */
/* Get file creation property list for output file */
if((fcpl_out = H5Fget_create_plist(fidout)) < 0) {
- error_msg("failed to retrieve file creation property list\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed to retrieve file creation property list");
}
/* Get file space info for output file */
if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0) {
- error_msg("failed to retrieve file space strategy & threshold\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_strategy failed to retrieve file space strategy & threshold");
}
/* Get file space page size for output file */
if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0) {
- error_msg("failed to retrieve file space page size\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fget_create_plist failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space page size");
}
/*
@@ -250,12 +231,11 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_strategy) {
if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy)) {
- error_msg("file space strategy not set as unexpected\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
}
- } else {
+ }
+ else {
if(out_strategy != in_strategy) {
- error_msg("file space strategy not set as unexpected\n");
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
}
}
@@ -267,13 +247,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_persist) {
if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) {
- error_msg("free-space persist status is not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
}
- } else {
+ }
+ else {
if(out_persist != in_persist) {
- error_msg("free-space persist status is not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
}
}
@@ -284,13 +263,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_threshold) {
if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) {
- error_msg("threshold is not set as unexpectec\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
}
- } else {
+ }
+ else {
if(out_threshold != in_threshold) {
- error_msg("threshold is not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
}
}
@@ -301,13 +279,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
*/
if(options->fs_pagesize) {
if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) {
- error_msg("file space page size is not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
}
- } else { /* "-G" is not set */
+ }
+ else { /* "-G" is not set */
if(out_pagesize != in_pagesize) {
- error_msg("file space page size is not set as unexpected\n");
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
}
}
@@ -339,8 +316,6 @@ done:
return ret_value;
} /* h5repack_verify() */
-
-
/*-------------------------------------------------------------------------
* Function: verify_layout
*
@@ -351,16 +326,10 @@ done:
* H5D_CHUNKED = 2
*
* Return: 1 has, 0 does not, -1 error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 30, 2003
- *
*-------------------------------------------------------------------------
*/
-int verify_layout(hid_t pid,
- pack_info_t *obj)
+int verify_layout(hid_t pid, pack_info_t *obj)
{
hsize_t chsize[64]; /* chunk size in elements */
H5D_layout_t layout; /* layout */
@@ -383,8 +352,7 @@ int verify_layout(hid_t pid,
if (obj->layout != layout)
return 0;
- if (layout==H5D_CHUNKED)
- {
+ if (layout==H5D_CHUNKED) {
if ((rank = H5Pget_chunk(pid,NELMTS(chsize),chsize/*out*/)) < 0)
return -1;
if (obj->chunk.rank != rank)
@@ -403,16 +371,10 @@ int verify_layout(hid_t pid,
* Purpose: compare 2 files for identical property lists of all objects
*
* Return: 1=identical, 0=not identical, -1=error
- *
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
- *
- * Date: December 31, 2003
- *
*-------------------------------------------------------------------------
*/
-int h5repack_cmp_pl(const char *fname1,
- const char *fname2)
+int h5repack_cmp_pl(const char *fname1, const char *fname2)
{
int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
hid_t fid1=-1; /* file ID */
@@ -439,13 +401,11 @@ int h5repack_cmp_pl(const char *fname1,
{
/* Open the files */
- if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
- {
+ if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) {
error_msg("<%s>: %s\n", fname1, H5FOPENERROR );
return -1;
}
- if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
- {
+ if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 ) {
error_msg("<%s>: %s\n", fname2, H5FOPENERROR );
H5Fclose(fid1);
return -1;
@@ -468,14 +428,10 @@ int h5repack_cmp_pl(const char *fname1,
* traverse the suppplied object list
*-------------------------------------------------------------------------
*/
- for(i = 0; i < trav->nobjs; i++)
- {
-
- if(trav->objs[i].type == H5TRAV_TYPE_GROUP)
- {
-
+ for(i = 0; i < trav->nobjs; i++) {
+ if(trav->objs[i].type == H5TRAV_TYPE_GROUP) {
if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on first <%s>", trav->objs[i].name);
if ((gcplid = H5Gget_create_plist(gid)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0)
@@ -486,7 +442,7 @@ int h5repack_cmp_pl(const char *fname1,
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed on second <%s>", trav->objs[i].name);
if ((gcplid = H5Gget_create_plist(gid)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0)
@@ -497,20 +453,14 @@ int h5repack_cmp_pl(const char *fname1,
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if (crt_order_flag1 != crt_order_flag2) {
- error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
}
-
}
-
-
-
- else if(trav->objs[i].type == H5TRAV_TYPE_DATASET)
- {
+ else if(trav->objs[i].type == H5TRAV_TYPE_DATASET) {
if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on first <%s>", trav->objs[i].name);
if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed on second <%s>", trav->objs[i].name);
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
@@ -524,8 +474,7 @@ int h5repack_cmp_pl(const char *fname1,
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
if(ret == 0) {
- error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed for <%s> are different",trav->objs[i].name);
}
/*-------------------------------------------------------------------------
@@ -593,11 +542,6 @@ done:
* 1 match
* 0 do not match
* -1 error
- *
- * Programmer: Pedro Vicente, pvn@hdfgroup.org
- *
- * Date: December 21, 2007
- *
*-------------------------------------------------------------------------
*/
@@ -621,11 +565,11 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
/* if we do not have filters and the requested filter is NONE, return 1 */
if(!nfilters_dcpl &&
nfilters == 1 &&
- filter[0].filtn == H5Z_FILTER_NONE )
+ filter[0].filtn == H5Z_FILTER_NONE)
return 1;
/* else the numbers of filters must match */
- if (nfilters_dcpl != nfilters )
+ if (nfilters_dcpl != nfilters)
return 0;
/*-------------------------------------------------------------------------
@@ -633,8 +577,7 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
*-------------------------------------------------------------------------
*/
- for( i = 0; i < nfilters_dcpl; i++)
- {
+ for (i = 0; i < nfilters_dcpl; i++) {
cd_nelmts = NELMTS(cd_values);
filtn = H5Pget_filter2(pid, (unsigned)i, &filt_flags, &cd_nelmts,
cd_values, sizeof(f_name), f_name, NULL);
@@ -644,15 +587,13 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
return 0;
/* compare client data values. some filters do return local values */
- switch (filtn)
- {
-
+ switch (filtn) {
case H5Z_FILTER_NONE:
break;
case H5Z_FILTER_SHUFFLE:
/* 1 private client value is returned by DCPL */
- if ( cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS )
+ if (cd_nelmts != H5Z_SHUFFLE_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SHUFFLE_USER_NPARMS)
return 0;
/* get dataset's type size */
@@ -660,31 +601,31 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
return -1;
/* the private client value holds the dataset's type size */
- if ( size != cd_values[0] )
+ if (size != cd_values[0])
return 0;
break;
case H5Z_FILTER_SZIP:
/* 4 private client values are returned by DCPL */
- if ( cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS )
+ if (cd_nelmts != H5Z_SZIP_TOTAL_NPARMS && filter[i].cd_nelmts != H5Z_SZIP_USER_NPARMS)
return 0;
/* "User" parameter for pixels-per-block (index 1) */
- if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] )
+ if (cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB])
return 0;
break;
case H5Z_FILTER_NBIT:
/* only client data values number of values checked */
- if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
+ if (H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
return 0;
break;
case H5Z_FILTER_SCALEOFFSET:
/* only client data values checked */
- for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
+ for (j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
if (cd_values[j] != filter[i].cd_values[j])
return 0;
break;
@@ -693,20 +634,20 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
case H5Z_FILTER_FLETCHER32:
case H5Z_FILTER_DEFLATE:
- if ( cd_nelmts != filter[i].cd_nelmts)
+ if (cd_nelmts != filter[i].cd_nelmts)
return 0;
- for( j = 0; j < cd_nelmts; j++)
+ for (j = 0; j < cd_nelmts; j++)
if (cd_values[j] != filter[i].cd_values[j])
return 0;
break;
default:
- if ( cd_nelmts != filter[i].cd_nelmts)
+ if (cd_nelmts != filter[i].cd_nelmts)
return 0;
- for( j = 0; j < cd_nelmts; j++)
+ for (j = 0; j < cd_nelmts; j++)
if (cd_values[j] != filter[i].cd_values[j])
return 0;
break;