summaryrefslogtreecommitdiffstats
path: root/tools/h5repack/h5repack_verify.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/h5repack/h5repack_verify.c')
-rw-r--r--tools/h5repack/h5repack_verify.c247
1 files changed, 111 insertions, 136 deletions
diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c
index cec9c86..f393dd1 100644
--- a/tools/h5repack/h5repack_verify.c
+++ b/tools/h5repack/h5repack_verify.c
@@ -51,11 +51,12 @@ static int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *fil
int
h5repack_verify(const char *out_fname, pack_opt_t *options)
{
- hid_t fidout; /* file ID for output file*/
- hid_t did; /* dataset ID */
- hid_t pid; /* dataset creation property list ID */
- hid_t sid; /* space ID */
- hid_t tid; /* type ID */
+ int ret_value = 0; /*no need to LEAVE() on ERROR: HERR_INIT(int, SUCCEED) */
+ hid_t fidout = -1; /* file ID for output file*/
+ hid_t did = -1; /* dataset ID */
+ hid_t pid = -1; /* dataset creation property list ID */
+ hid_t sid = -1; /* space ID */
+ hid_t tid = -1; /* type ID */
unsigned int i;
trav_table_t *travt = NULL;
int ok = 1;
@@ -74,20 +75,20 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((sid = H5Dget_space(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
*-------------------------------------------------------------------------
*/
if(verify_filters(pid, tid, obj->nfilters, obj->filter) <= 0)
- ok = 0;
+ ok = 0;
/*-------------------------------------------------------------------------
@@ -102,13 +103,13 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if(H5Pclose(pid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Sclose(sid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if (H5Dclose(did) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if (H5Tclose(tid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
}
@@ -126,7 +127,7 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
/* get the list of objects in the file */
if(h5trav_gettable(fidout, travt) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
for(i = 0; i < travt->nobjs; i++)
{
@@ -140,13 +141,13 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if((did = H5Dopen2(fidout, name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((sid = H5Dget_space(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed");
if((pid = H5Dget_create_plist(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((tid = H5Dget_type(did)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_type failed");
/*-------------------------------------------------------------------------
* filter check
@@ -154,7 +155,6 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*/
if(options->all_filter == 1)
{
-
if(verify_filters(pid, tid, options->n_filter_g, options->filter_g) <= 0)
ok = 0;
}
@@ -166,6 +166,7 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
if(options->all_layout == 1)
{
pack_info_t pack;
+
init_packobject(&pack);
pack.layout = options->layout_g;
pack.chunk = options->chunk_g;
@@ -179,13 +180,13 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*-------------------------------------------------------------------------
*/
if (H5Pclose(pid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Sclose(sid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sclose failed");
if (H5Dclose(did) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if (H5Tclose(tid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tclose failed");
} /* if */
} /* i */
@@ -200,20 +201,24 @@ h5repack_verify(const char *out_fname, pack_opt_t *options)
*/
if (H5Fclose(fidout) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed");
return ok;
-error:
+done:
H5E_BEGIN_TRY {
+ H5Pclose(fcpl_in);
+ H5Pclose(fcpl_out);
H5Pclose(pid);
H5Sclose(sid);
H5Dclose(did);
+ H5Fclose(fidin);
H5Fclose(fidout);
if (travt)
trav_table_free(travt);
} H5E_END_TRY;
- return -1;
+
+ return ret_value;
} /* h5repack_verify() */
@@ -291,6 +296,7 @@ int verify_layout(hid_t pid,
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 */
hid_t fid2=-1; /* file ID */
hid_t dset1=-1; /* dataset ID */
@@ -315,12 +321,12 @@ 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);
@@ -335,7 +341,7 @@ int h5repack_cmp_pl(const char *fname1,
*/
trav_table_init(&trav);
if(h5trav_gettable(fid1, trav) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5trav_gettable failed");
/*-------------------------------------------------------------------------
* traverse the suppplied object list
@@ -348,31 +354,30 @@ int h5repack_cmp_pl(const char *fname1,
{
if ((gid = H5Gopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Gclose(gid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
if ((gid = H5Gopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gopen2 failed");
if ((gcplid = H5Gget_create_plist(gid)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gget_create_plist failed");
if (H5Pget_link_creation_order(gcplid, &crt_order_flag2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_link_creation_order failed");
if (H5Pclose(gcplid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if (H5Gclose(gid) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
- if ( crt_order_flag1 != crt_order_flag2 )
- {
+ if (crt_order_flag1 != crt_order_flag2) {
error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
}
}
@@ -382,25 +387,24 @@ int h5repack_cmp_pl(const char *fname1,
else if(trav->objs[i].type == H5TRAV_TYPE_DATASET)
{
if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dset2 = H5Dopen2(fid2, trav->objs[i].name, H5P_DEFAULT)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed");
if((dcpl1 = H5Dget_create_plist(dset1)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
if((dcpl2 = H5Dget_create_plist(dset2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_create_plist failed");
/*-------------------------------------------------------------------------
* compare the property lists
*-------------------------------------------------------------------------
*/
if((ret = H5Pequal(dcpl1, dcpl2)) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
- if(ret == 0)
- {
+ if(ret == 0) {
error_msg("property lists for <%s> are different\n",trav->objs[i].name);
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "property lists failed");
}
/*-------------------------------------------------------------------------
@@ -408,13 +412,13 @@ int h5repack_cmp_pl(const char *fname1,
*-------------------------------------------------------------------------
*/
if(H5Pclose(dcpl1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Pclose(dcpl2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed");
if(H5Dclose(dset1) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
if(H5Dclose(dset2) < 0)
- goto error;
+ HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed");
} /*if*/
} /*i*/
@@ -432,14 +436,14 @@ int h5repack_cmp_pl(const char *fname1,
H5Fclose(fid1);
H5Fclose(fid2);
- return ret;
- /*-------------------------------------------------------------------------
- * error
- *-------------------------------------------------------------------------
- */
+ return ret;
-error:
+/*-------------------------------------------------------------------------
+* error
+*-------------------------------------------------------------------------
+*/
+done:
H5E_BEGIN_TRY
{
H5Pclose(dcpl1);
@@ -452,8 +456,8 @@ error:
H5Gclose(gid);
trav_table_free(trav);
} H5E_END_TRY;
- return -1;
+ return ret_value;
}
@@ -522,100 +526,71 @@ int verify_filters(hid_t pid, hid_t tid, int nfilters, filter_info_t *filter)
switch (filtn)
{
- case H5Z_FILTER_NONE:
+ 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 )
- return 0;
-
- /* get dataset's type size */
- if((size = H5Tget_size(tid)) <= 0)
- return -1;
-
- /* the private client value holds the dataset's type size */
- 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 )
- 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] )
- return 0;
-
-
- break;
-
- case H5Z_FILTER_NBIT:
-
- /* only client data values number of values checked */
- if ( H5Z_NBIT_USER_NPARMS != filter[i].cd_nelmts)
- return 0;
-
-
-
- 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 )
+ return 0;
- case H5Z_FILTER_SCALEOFFSET:
+ /* get dataset's type size */
+ if((size = H5Tget_size(tid)) <= 0)
+ return -1;
- /* only client data values checked */
- for( j = 0; j < H5Z_SCALEOFFSET_USER_NPARMS; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
+ /* the private client value holds the dataset's type size */
+ if ( size != cd_values[0] )
return 0;
- }
-
- }
+ break;
- 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 )
+ return 0;
- /* for these filters values must match, no local values set in DCPL */
- case H5Z_FILTER_FLETCHER32:
- case H5Z_FILTER_DEFLATE:
+ /* "User" parameter for pixels-per-block (index 1) */
+ if ( cd_values[H5Z_SZIP_PARM_PPB] != filter[i].cd_values[H5Z_SZIP_PARM_PPB] )
+ return 0;
- if ( cd_nelmts != filter[i].cd_nelmts)
- return 0;
+ break;
- for( j = 0; j < cd_nelmts; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
+ case H5Z_FILTER_NBIT:
+ /* only client data values number of values checked */
+ 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++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
+ break;
+ /* for these filters values must match, no local values set in DCPL */
+ case H5Z_FILTER_FLETCHER32:
+ case H5Z_FILTER_DEFLATE:
+ if ( cd_nelmts != filter[i].cd_nelmts)
+ return 0;
- break;
+ for( j = 0; j < cd_nelmts; j++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
- default:
- if ( cd_nelmts != filter[i].cd_nelmts)
- return 0;
+ break;
- for( j = 0; j < cd_nelmts; j++)
- {
- if (cd_values[j] != filter[i].cd_values[j])
- {
- return 0;
- }
+ default:
+ if ( cd_nelmts != filter[i].cd_nelmts)
+ return 0;
- }
- break;
+ for( j = 0; j < cd_nelmts; j++)
+ if (cd_values[j] != filter[i].cd_values[j])
+ return 0;
+ break;
} /* switch */
-
}
return 1;