summaryrefslogtreecommitdiffstats
path: root/tools/src/h5repack/h5repack_verify.c
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2017-10-10 18:06:12 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2017-10-10 18:06:12 (GMT)
commit0c07376431a6882ee6b6d437a462796d758cb42c (patch)
treee3dc3942f1956d9968558d45a3244ea8d6c78382 /tools/src/h5repack/h5repack_verify.c
parent2f636b5d4a067465d458f825823728cd4a9e568e (diff)
downloadhdf5-0c07376431a6882ee6b6d437a462796d758cb42c.zip
hdf5-0c07376431a6882ee6b6d437a462796d758cb42c.tar.gz
hdf5-0c07376431a6882ee6b6d437a462796d758cb42c.tar.bz2
HDFFV-10297 Fix resource errors and cleanup whitespace
Diffstat (limited to 'tools/src/h5repack/h5repack_verify.c')
-rw-r--r--tools/src/h5repack/h5repack_verify.c98
1 files changed, 46 insertions, 52 deletions
diff --git a/tools/src/h5repack/h5repack_verify.c b/tools/src/h5repack/h5repack_verify.c
index bf53bf9..dbe8e1a 100644
--- a/tools/src/h5repack/h5repack_verify.c
+++ b/tools/src/h5repack/h5repack_verify.c
@@ -177,6 +177,7 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
/* free table */
trav_table_free(travt);
+ travt = NULL;
}
/*-------------------------------------------------------------------------
@@ -185,39 +186,33 @@ 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 )
+ if((fidin = H5Fopen(in_fname, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
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) {
+ if((fcpl_in = H5Fget_create_plist(fidin)) < 0)
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) {
+ if(H5Pget_file_space_strategy(fcpl_in, &in_strategy, &in_persist, &in_threshold) < 0)
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) {
+ if(H5Pget_file_space_page_size(fcpl_in, &in_pagesize) < 0)
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) {
+ if((fcpl_out = H5Fget_create_plist(fidout)) < 0)
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) {
+ if(H5Pget_file_space_strategy(fcpl_out, &out_strategy, &out_persist, &out_threshold) < 0)
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) {
+ if(H5Pget_file_space_page_size(fcpl_out, &out_pagesize) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pget_file_space_page_size failed to retrieve file space page size");
- }
/*
* If -S option is set, the file space handling strategy should be set as specified.
@@ -225,14 +220,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* the same as the input file's strategy.
*/
if(options->fs_strategy) {
- if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy)) {
+ if(out_strategy != (options->fs_strategy == (H5F_fspace_strategy_t)-1 ? 0 : options->fs_strategy))
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
- }
}
else {
- if(out_strategy != in_strategy) {
+ if(out_strategy != in_strategy)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space strategy not set as unexpected");
- }
}
/*
@@ -241,14 +234,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* the same as the input file's free-space persist status
*/
if(options->fs_persist) {
- if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist)) {
+ if(out_persist != (hbool_t)(options->fs_persist == (-1) ? FALSE : options->fs_persist))
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
- }
}
else {
- if(out_persist != in_persist) {
+ if(out_persist != in_persist)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "free-space persist status not set as unexpected");
- }
}
/*
@@ -257,14 +248,12 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* input file's threshold size.
*/
if(options->fs_threshold) {
- if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold)) {
+ if(out_threshold != (hsize_t)(options->fs_threshold == (-1) ? 0 : options->fs_threshold))
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
- }
}
else {
- if(out_threshold != in_threshold) {
+ if(out_threshold != in_threshold)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "threshold not set as unexpected");
- }
}
/*
@@ -273,14 +262,13 @@ h5repack_verify(const char *in_fname, const char *out_fname, pack_opt_t *options
* the same as the input file's file space page size.
*/
if(options->fs_pagesize) {
- if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize)) {
+ if(out_pagesize != (hsize_t)(options->fs_pagesize == (-1) ? 0 : options->fs_pagesize))
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
- }
}
else { /* "-G" is not set */
- if(out_pagesize != in_pagesize) {
+ if(out_pagesize != in_pagesize)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "file space page size not set as unexpected");
- }
+
}
ret_value = ok;
@@ -292,6 +280,7 @@ done:
H5Pclose(pid);
H5Sclose(sid);
H5Dclose(did);
+ H5Tclose(tid);
H5Fclose(fidin);
H5Fclose(fidout);
if (travt)
@@ -304,13 +293,15 @@ done:
/*-------------------------------------------------------------------------
* Function: verify_layout
*
- * Purpose: verify which layout is present in the property list DCPL_ID
- *
- * H5D_COMPACT = 0
- * H5D_CONTIGUOUS = 1
- * H5D_CHUNKED = 2
+ * Purpose: verify which layout is present in the property list DCPL_ID
+ * H5D_COMPACT = 0
+ * H5D_CONTIGUOUS = 1
+ * H5D_CHUNKED = 2
*
- * Return: 1 has, 0 does not, -1 error
+ * Return:
+ * 1 has,
+ * 0 does not,
+ * -1 error
*-------------------------------------------------------------------------
*/
@@ -327,7 +318,7 @@ int verify_layout(hid_t pid, pack_info_t *obj)
return -1;
/* a non chunked layout was requested on a filtered object */
- if (nfilters && obj->layout!=H5D_CHUNKED)
+ if (nfilters && obj->layout != H5D_CHUNKED)
return 0;
/* get layout */
@@ -338,11 +329,11 @@ int verify_layout(hid_t pid, pack_info_t *obj)
return 0;
if (layout==H5D_CHUNKED) {
- if ((rank = H5Pget_chunk(pid,NELMTS(chsize),chsize/*out*/)) < 0)
+ if ((rank = H5Pget_chunk(pid, NELMTS(chsize), chsize/*out*/)) < 0)
return -1;
if (obj->chunk.rank != rank)
return 0;
- for ( i=0; i<rank; i++)
+ for (i = 0; i < rank; i++)
if (chsize[i] != obj->chunk.chunk_lengths[i])
return 0;
}
@@ -353,9 +344,12 @@ int verify_layout(hid_t pid, pack_info_t *obj)
/*-------------------------------------------------------------------------
* Function: h5repack_cmp_pl
*
- * Purpose: compare 2 files for identical property lists of all objects
+ * Purpose: compare 2 files for identical property lists of all objects
*
- * Return: 1=identical, 0=not identical, -1=error
+ * Return:
+ * 1 = identical,
+ * 0 = not identical,
+ * -1 = error
*-------------------------------------------------------------------------
*/
@@ -380,9 +374,9 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
*-------------------------------------------------------------------------
*/
/* Open the files */
- if ((fid1 = H5Fopen(fname1,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ if ((fid1 = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname1, H5FOPENERROR);
- if ((fid2 = H5Fopen(fname2,H5F_ACC_RDONLY,H5P_DEFAULT)) < 0 )
+ if ((fid2 = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname2, H5FOPENERROR);
/*-------------------------------------------------------------------------
@@ -424,9 +418,8 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
if (H5Gclose(gid) < 0)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Gclose failed");
- if (crt_order_flag1 != crt_order_flag2) {
+ if (crt_order_flag1 != crt_order_flag2)
HGOTO_ERROR(0, 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) {
if((dset1 = H5Dopen2(fid1, trav->objs[i].name, H5P_DEFAULT)) < 0)
@@ -446,7 +439,7 @@ int h5repack_cmp_pl(const char *fname1, const char *fname2)
HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pequal failed");
if(ret_value == 0)
- HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different",trav->objs[i].name);
+ HGOTO_ERROR(0, H5E_tools_min_id_g, "property lists failed for <%s> are different", trav->objs[i].name);
/*-------------------------------------------------------------------------
* close
@@ -474,7 +467,8 @@ done:
H5Fclose(fid2);
H5Pclose(gcplid);
H5Gclose(gid);
- trav_table_free(trav);
+ if(trav)
+ trav_table_free(trav);
} H5E_END_TRY;
return ret_value;
@@ -484,14 +478,14 @@ done:
/*-------------------------------------------------------------------------
* Function: verify_filters
*
- * Purpose: verify if all requested filters in the array FILTER obtained
- * from user input are present in the property list PID obtained from
- * the output file
+ * Purpose: verify if all requested filters in the array FILTER obtained
+ * from user input are present in the property list PID obtained from
+ * the output file
*
* Return:
- * 1 match
- * 0 do not match
- * -1 error
+ * 1 match
+ * 0 do not match
+ * -1 error
*-------------------------------------------------------------------------
*/