diff options
Diffstat (limited to 'tools/src')
-rw-r--r-- | tools/src/h5repack/h5repack.c | 40 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_copy.c | 32 | ||||
-rw-r--r-- | tools/src/h5repack/h5repack_main.c | 12 |
3 files changed, 40 insertions, 44 deletions
diff --git a/tools/src/h5repack/h5repack.c b/tools/src/h5repack/h5repack.c index a8b1458..7dc38e6 100644 --- a/tools/src/h5repack/h5repack.c +++ b/tools/src/h5repack/h5repack.c @@ -247,8 +247,7 @@ copy_named_datatype(hid_t type_in, for (i = 0; i < travt->nobjs; i++) { if (travt->objs[i].type == H5TRAV_TYPE_NAMED_DATATYPE) { /* Push onto the stack */ - dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)); - if (NULL == dt) + if (NULL == (dt = (named_dt_t *)HDmalloc(sizeof(named_dt_t)))) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "buffer allocation failed failed"); dt->next = *named_dt_head_p; @@ -397,20 +396,17 @@ copy_attr( if (H5Aget_name(attr_id, (size_t) 255, name) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); - ftype_id = H5Aget_type(attr_id); - if (ftype_id < 0) + if ((ftype_id = H5Aget_type(attr_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Aget_type failed"); /* Check if the datatype is committed */ - is_named = H5Tcommitted(ftype_id); - if (is_named < 0) + if ((is_named = H5Tcommitted(ftype_id)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Tcommitted failed"); if (is_named && travt) { hid_t fidout = -1; /* Create out file id */ - fidout = H5Iget_file_id(loc_out); - if (fidout < 0) + if ((fidout = H5Iget_file_id(loc_out)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Iget_file_id failed"); /* Copy named dt */ @@ -428,13 +424,13 @@ copy_attr( if (H5Fclose(fidout) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Fclose failed"); - } + } /* end if datatype is committed and we have a traversal table */ else { if (options->use_native == 1) wtype_id = H5Tget_native_type(ftype_id, H5T_DIR_DEFAULT); else wtype_id = H5Tcopy(ftype_id); - } + } /* end else: uncommitted datatype and/or no traversal table */ /* get the dataspace handle */ if ((space_id = H5Aget_space(attr_id)) < 0) @@ -673,12 +669,12 @@ check_options(pack_opt_t *options) default: printf(" User Defined %d\n", filtn); break; - } - } - } + } /* end switch */ + } /* end for each filter */ + } /* end if options->all_filter == 1 (TODO: meaning) */ else printf("No all objects to apply filter\n"); - } /* verbose */ + } /* end if verbose */ for (i = 0; i < options->op_tbl->nelems; i++) { pack_info_t pack = options->op_tbl->objs[i]; @@ -699,7 +695,7 @@ check_options(pack_opt_t *options) } } has_cp = 1; - } /* for each filter */ + } /* end for each filter */ } /* end for each object in options table */ if (options->all_filter == 1 && has_cp) @@ -782,8 +778,7 @@ check_objects(const char* fname, pack_opt_t *options) * open the file *------------------------------------------------------------------------- */ - fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0); - if (fid < 0) + if ((fid = h5tools_fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT, NULL, NULL, 0)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "h5tools_fopen failed <%s>: %s", fname, H5FOPENERROR); @@ -843,16 +838,13 @@ check_objects(const char* fname, pack_opt_t *options) csize *= obj.chunk.chunk_lengths[j]; } else { - did = H5Dopen2(fid, name, H5P_DEFAULT); - if (did < 0) + if ((did = H5Dopen2(fid, name, H5P_DEFAULT)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dopen2 failed"); - sid = H5Dget_space(did); - if (sid < 0) + if ((sid = H5Dget_space(did)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dget_space failed"); - rank = H5Sget_simple_extent_ndims(sid); - if (rank < 0) + if ((rank = H5Sget_simple_extent_ndims(sid)) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Sget_simple_extent_ndims failed"); HDmemset(dims, 0, sizeof dims); @@ -873,7 +865,7 @@ check_objects(const char* fname, pack_opt_t *options) printf(" <warning: SZIP settings, chunk size is smaller than pixels per block>\n"); HGOTO_DONE(0); } - } /* end SZIP */ + } /* end case SZIP */ break; default: break; diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c index c638f3d..0d6a6c5 100644 --- a/tools/src/h5repack/h5repack_copy.c +++ b/tools/src/h5repack/h5repack_copy.c @@ -785,9 +785,6 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dclose(dset_in) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); -/* TODO: be smart about external storage */ -/* can we use the dcpl_in/out to adjust any external storage? */ -/* what about the case with just H5Ocopy? */ /*------------------------------------------------------------------------- * check if we should use H5Ocopy or not * if there is a request for filters/layout, we read/write the object @@ -914,8 +911,8 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, /* unset unlimited max dims */ if (limit_maxdims) H5Sset_extent_simple(f_space_id, rank, dims, NULL); - } /* if not chunked */ - } /* if layout change requested for entire file or individual object */ + } /* end if not chunked */ + } /* end if layout change requested for entire file or individual object */ /*------------------------------------------------------------------------- * create the output dataset; @@ -930,6 +927,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5P_DEFAULT, dcpl_out, H5P_DEFAULT); + /* if unable to create, retry with original DCPL */ if (dset_out < 0) { H5Epush2(H5tools_ERR_STACK_g, __FILE__, @@ -952,7 +950,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (dset_out < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dcreate2 failed"); apply_f = 0; - } /* if opening dataset with original DCPL (retry) */ + } /* end if retry dataset create */ /*------------------------------------------------------------------------- * read/write @@ -1079,7 +1077,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, H5Sselect_all(f_space_id); H5Sselect_all(hslab_space); hs_select_nelmts = 1; - } /* rank == 0 */ + } /* end (else) rank == 0 */ if (H5Dread( dset_in, @@ -1112,7 +1110,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, else carry = 0; } - } /* hyperslab selection loop */ + } /* end for (hyperslab selection loop) */ H5Sclose(hslab_space); if (hslab_buf != NULL) { @@ -1120,7 +1118,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, hslab_buf = NULL; } } /* end if reading/writing by hyperslab */ - } /* if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ + } /* end if (nelmts > 0 && space_status != H5D_SPACE_STATUS_NOT_ALLOCATED) */ /*------------------------------------------------------------------------- * print amount of compression used @@ -1152,7 +1150,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (has_filter && apply_f == 0) printf(" <warning: could not apply the filter to %s>\n", travt->objs[i].name); - } /* if verbose (print compression) */ + } /* end if verbose (print compression) */ /*------------------------------------------------------------------------- * copy attrs @@ -1163,11 +1161,11 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, if (H5Dclose(dset_out) < 0) HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); - } /* !H5T_REFERENCE */ - } /* if h5tools_canreadf (filter availability check) */ + } /* end if not a reference */ + } /* end if h5tools_canreadf (filter availability check) */ /*------------------------------------------------------------------------- - * close + * Close *------------------------------------------------------------------------- */ if (H5Tclose(ftype_id) < 0) @@ -1184,7 +1182,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Dclose failed"); } /*------------------------------------------------------------------------- - * we do not have request for filter/chunking; use H5Ocopy instead + * We do not have request for filter/chunking; use H5Ocopy instead *------------------------------------------------------------------------- */ else { @@ -1210,7 +1208,7 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt, HGOTO_ERROR(FAIL, H5E_tools_min_id_g, "H5Pclose failed"); /*------------------------------------------------------------------------- - * copy attrs manually + * Copy attrs manually *------------------------------------------------------------------------- */ if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0) @@ -1420,8 +1418,8 @@ print_dataset_info(hid_t dcpl_id, char *objname, double ratio, int pr) default: HDstrcat(strfilter, "UD "); break; - } /* switch */ - } /* for each filter */ + } /* end switch */ + } /* end for each filter */ if (!pr) printf(FORMAT_OBJ, "dset", objname); diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index efab3f0..19eabd0 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -282,8 +282,7 @@ int read_info(const char *filename, pack_opt_t *options) int i, rc = 1; int ret_value = EXIT_SUCCESS; - fp = HDfopen(filename, "r"); - if ((FILE *)NULL == fp) { + if (NULL == (fp = HDfopen(filename, "r"))) { error_msg("cannot open options file %s\n", filename); h5tools_setstatus(EXIT_FAILURE); ret_value = EXIT_FAILURE; @@ -417,7 +416,14 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) int ret_value = 0; /* parse command line options */ +#if 0 while (EOF != (opt = get_option(argc, argv, s_opts, l_opts))) { +#else + for (opt = get_option(argc, argv, s_opts, l_opts); + opt != EOF; + opt = get_option(argc, argv, s_opts, l_opts)) + { +#endif switch ((char) opt) { /* -i for backward compatibility */ @@ -654,7 +660,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options) default: break; - } /* switch */ + } /* end switch */ } /* end while there are more options to parse */ /* If neither -i nor -o given, get in and out files positionally */ |