summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJordan Henderson <jhenderson@hdfgroup.org>2020-04-03 22:09:24 (GMT)
committerJordan Henderson <jhenderson@hdfgroup.org>2020-04-03 22:09:24 (GMT)
commit95c04dc836b4176930fce613d00fdd99bd0759c7 (patch)
tree62da5499c4c051016c31431375960aa54969e279 /tools
parent4573b87b1d1c10700a971037b6fa36d21ef7124f (diff)
downloadhdf5-95c04dc836b4176930fce613d00fdd99bd0759c7.zip
hdf5-95c04dc836b4176930fce613d00fdd99bd0759c7.tar.gz
hdf5-95c04dc836b4176930fce613d00fdd99bd0759c7.tar.bz2
H5repack bug fixes from develop
Diffstat (limited to 'tools')
-rw-r--r--tools/src/h5repack/h5repack_copy.c18
-rw-r--r--tools/src/h5repack/h5repack_main.c48
2 files changed, 50 insertions, 16 deletions
diff --git a/tools/src/h5repack/h5repack_copy.c b/tools/src/h5repack/h5repack_copy.c
index b85a63f..eb6f5c6 100644
--- a/tools/src/h5repack/h5repack_copy.c
+++ b/tools/src/h5repack/h5repack_copy.c
@@ -702,11 +702,14 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
break;
- /*-------------------------------------------------------------------------
- * H5TRAV_TYPE_DATASET
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * H5TRAV_TYPE_DATASET
+ *-------------------------------------------------------------------------
+ */
case H5TRAV_TYPE_DATASET:
+ {
+ hbool_t use_h5ocopy;
+
has_filter = 0;
req_filter = 0;
@@ -764,9 +767,10 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
* otherwise we do a copy using H5Ocopy
*-------------------------------------------------------------------------
*/
- if (options->op_tbl->nelems || options->all_filter == 1
- || options->all_layout == 1 || is_ref || is_named) {
+ use_h5ocopy = !(options->op_tbl->nelems || options->all_filter == 1
+ || options->all_layout == 1 || is_ref || is_named);
+ if (!use_h5ocopy) {
int j;
if ((dset_in = H5Dopen2(fidin, travt->objs[i].name, H5P_DEFAULT)) < 0)
@@ -1135,7 +1139,9 @@ do_copy_objects(hid_t fidin, hid_t fidout, trav_table_t *travt,
HDprintf(FORMAT_OBJ, "dset", travt->objs[i].name);
} /* end whether we have request for filter/chunking */
+
break;
+ } /* H5TRAV_TYPE_DATASET */
/*-------------------------------------------------------------------------
* H5TRAV_TYPE_NAMED_DATATYPE
diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c
index de14566..0822b16 100644
--- a/tools/src/h5repack/h5repack_main.c
+++ b/tools/src/h5repack/h5repack_main.c
@@ -291,6 +291,8 @@ int read_info(const char *filename, pack_opt_t *options)
/* cycle until end of file reached */
while (1) {
+ if (EOF == fscanf(fp, "%9s", stype))
+ break;
/* Info indicator must be for layout or filter */
if (HDstrcmp(stype,"-l") && HDstrcmp(stype, "-f")) {
@@ -332,7 +334,7 @@ int read_info(const char *filename, pack_opt_t *options)
if (!HDstrcmp(stype, "-l")) {
if (h5repack_addlayout(comp_info, options) == -1) {
- error_msg("could not add chunck option\n");
+ error_msg("could not add chunk option\n");
h5tools_setstatus(EXIT_FAILURE);
ret_value = EXIT_FAILURE;
goto done;
@@ -432,13 +434,13 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
case 'h':
usage(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'V':
print_version(h5tools_getprogname());
h5tools_setstatus(EXIT_SUCCESS);
- ret_value = -1;
+ ret_value = 1;
goto done;
case 'v':
@@ -476,9 +478,12 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'e':
- ret_value = read_info(opt_arg, options);
- if (ret_value < 0)
+ if ((ret_value = read_info(opt_arg, options)) < 0) {
+ error_msg("failed to read from repack options file <%s>\n", opt_arg);
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
+ }
break;
case 'n':
@@ -493,6 +498,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing low bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->low_bound = bound;
@@ -502,6 +509,8 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
bound = HDatoi(opt_arg);
if (bound < H5F_LIBVER_EARLIEST || bound > H5F_LIBVER_LATEST) {
error_msg("in parsing high bound\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ ret_value = -1;
goto done;
}
options->high_bound = bound;
@@ -623,7 +632,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'q':
- if (H5_INDEX_UNKNOWN == set_sort_by(opt_arg)) {
+ if (H5_INDEX_UNKNOWN == (sort_by = set_sort_by(opt_arg))) {
error_msg(" failed to set sort by form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
@@ -632,7 +641,7 @@ int parse_command_line(int argc, const char **argv, pack_opt_t* options)
break;
case 'z':
- if (set_sort_order(opt_arg) == H5_ITER_UNKNOWN) {
+ if (H5_ITER_UNKNOWN == (sort_order = set_sort_order(opt_arg))) {
error_msg(" failed to set sort order form <%s>\n", opt_arg);
h5tools_setstatus(EXIT_FAILURE);
ret_value = -1;
@@ -692,11 +701,12 @@ done:
*/
int main(int argc, const char **argv)
{
- pack_opt_t options; /*the global options */
+ pack_opt_t options; /*the global options */
H5E_auto2_t func;
H5E_auto2_t tools_func;
void *edata;
void *tools_edata;
+ int parse_ret;
HDmemset(&options, 0, sizeof(pack_opt_t));
@@ -716,20 +726,32 @@ int main(int argc, const char **argv)
/* update hyperslab buffer size from H5TOOLS_BUFSIZE env if exist */
if (h5tools_getenv_update_hyperslab_bufsize() < 0) {
+ HDprintf("Error occurred while retrieving H5TOOLS_BUFSIZE value\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
/* initialize options */
if (h5repack_init(&options, 0, FALSE) < 0) {
+ HDprintf("Error occurred while initializing repack options\n");
h5tools_setstatus(EXIT_FAILURE);
goto done;
}
+
/* Initialize default indexing options */
sort_by = H5_INDEX_CRT_ORDER;
- if (parse_command_line(argc, argv, &options) < 0)
+ parse_ret = parse_command_line(argc, argv, &options);
+ if (parse_ret < 0) {
+ HDprintf("Error occurred while parsing command-line options\n");
+ h5tools_setstatus(EXIT_FAILURE);
goto done;
+ }
+ else if (parse_ret > 0) {
+ /* Short-circuit success */
+ h5tools_setstatus(EXIT_SUCCESS);
+ goto done;
+ }
if (enable_error_stack > 0) {
H5Eset_auto2(H5E_DEFAULT, func, edata);
@@ -737,7 +759,13 @@ int main(int argc, const char **argv)
}
/* pack it */
- h5tools_setstatus(h5repack(infile, outfile, &options));
+ if (h5repack(infile, outfile, &options) < 0) {
+ HDprintf("Error occurred while repacking\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ h5tools_setstatus(EXIT_SUCCESS);
done:
/* free tables */