From 9676029742f18aaae37dd48947bc1faf23406169 Mon Sep 17 00:00:00 2001 From: Jordan Henderson Date: Sun, 29 Mar 2020 12:37:14 -0500 Subject: Fix latent bug in h5repack options file reading Add 'enable-error-stack' option to h5format_convert --- tools/src/h5format_convert/h5format_convert.c | 95 ++++++++++++++------------- tools/src/h5repack/h5repack_main.c | 2 + tools/test/h5format_convert/testh5fc.sh.in | 2 +- 3 files changed, 53 insertions(+), 46 deletions(-) diff --git a/tools/src/h5format_convert/h5format_convert.c b/tools/src/h5format_convert/h5format_convert.c index 01e7fe0..ae72ea9 100644 --- a/tools/src/h5format_convert/h5format_convert.c +++ b/tools/src/h5format_convert/h5format_convert.c @@ -42,13 +42,13 @@ static int verbose_g = 0; static const char *s_opts = "hVvd:n"; static struct long_options l_opts[] = { { "help", no_arg, 'h' }, - { "hel", no_arg, 'h'}, - { "he", no_arg, 'h'}, + { "hel", no_arg, 'h'}, + { "he", no_arg, 'h'}, { "version", no_arg, 'V' }, - { "version", no_arg, 'V' }, - { "versio", no_arg, 'V' }, - { "versi", no_arg, 'V' }, - { "vers", no_arg, 'V' }, + { "version", no_arg, 'V' }, + { "versio", no_arg, 'V' }, + { "versi", no_arg, 'V' }, + { "vers", no_arg, 'V' }, { "verbose", no_arg, 'v' }, { "verbos", no_arg, 'v' }, { "verbo", no_arg, 'v' }, @@ -60,6 +60,7 @@ static struct long_options l_opts[] = { { "noop", no_arg, 'n' }, { "noo", no_arg, 'n' }, { "no", no_arg, 'n' }, + { "enable-error-stack", no_arg, 'E' }, { NULL, 0, '\0' } }; @@ -120,55 +121,59 @@ parse_command_line(int argc, const char **argv) /* no arguments */ if (argc == 1) { usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { - switch((char) opt) { - case 'h': - usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'V': - print_version(h5tools_getprogname()); - h5tools_setstatus(EXIT_SUCCESS); - goto error; - - case 'v': - verbose_g = TRUE; - break; - - case 'd': /* -d dname */ - if(opt_arg != NULL && *opt_arg) - dname_g = HDstrdup(opt_arg); - if(dname_g == NULL) { - h5tools_setstatus(EXIT_FAILURE); - error_msg("No dataset name\n", opt_arg); - usage(h5tools_getprogname()); - goto error; - } - dset_g = TRUE; - break; - - case 'n': /* -n */ - noop_g = TRUE; - break; - - default: - h5tools_setstatus(EXIT_FAILURE); - usage(h5tools_getprogname()); - goto error; - break; - } /* switch */ + switch((char) opt) { + case 'h': + usage(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'V': + print_version(h5tools_getprogname()); + h5tools_setstatus(EXIT_SUCCESS); + goto error; + + case 'v': + verbose_g = TRUE; + break; + + case 'd': /* -d dname */ + if(opt_arg != NULL && *opt_arg) + dname_g = HDstrdup(opt_arg); + if(dname_g == NULL) { + h5tools_setstatus(EXIT_FAILURE); + error_msg("No dataset name\n", opt_arg); + usage(h5tools_getprogname()); + goto error; + } + dset_g = TRUE; + break; + + case 'n': /* -n */ + noop_g = TRUE; + break; + + case 'E': + enable_error_stack = 1; + break; + + default: + h5tools_setstatus(EXIT_FAILURE); + usage(h5tools_getprogname()); + goto error; + break; + } /* switch */ } /* while */ if (argc <= opt_ind) { error_msg("missing file name\n"); usage(h5tools_getprogname()); - h5tools_setstatus(EXIT_FAILURE); + h5tools_setstatus(EXIT_FAILURE); goto error; } diff --git a/tools/src/h5repack/h5repack_main.c b/tools/src/h5repack/h5repack_main.c index 44b4b6c..f0a94ab 100644 --- a/tools/src/h5repack/h5repack_main.c +++ b/tools/src/h5repack/h5repack_main.c @@ -311,6 +311,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")) { diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index 2cdd445..d780a3d 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.sh.in @@ -483,7 +483,7 @@ TOOLTEST_OUT h5fc_v_n_all.ddl h5fc_non_v3.h5 -v -n # # # h5format_convert -v h5fc_err_level.h5 (error encountered in converting the dataset) -TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v +TOOLTEST_MASK_OUT h5fc_v_err.ddl h5fc_err_level.h5 -v --enable-error-stack # # # -- cgit v0.12