From d8871197ea3e1cf38a9a097076eee487a1456220 Mon Sep 17 00:00:00 2001 From: Alexander Egorenkov Date: Mon, 11 Oct 2021 16:13:26 +0200 Subject: [PATCH] zdump/opts: Make command-line argument parsing independent of DFO MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Set DFO format after the parsing of command-line arguments is done. The command-line argument parsing should be independent of DFO. This improves testability of the command-line argument parsing and separates independent things from each other. Signed-off-by: Alexander Egorenkov Signed-off-by: Jan Höppner --- zdump/opts.c | 4 ---- zdump/zgetdump.c | 3 +++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/zdump/opts.c b/zdump/opts.c index 5c5ec995..b52c39c4 100644 --- a/zdump/opts.c +++ b/zdump/opts.c @@ -18,7 +18,6 @@ #include "lib/util_log.h" #include "opts.h" -#include "dfo.h" static struct option long_opts[] = { {"help", no_argument, NULL, 'h'}, @@ -92,7 +91,6 @@ static void init_defaults(struct options *opts) #else opts->fmt = "s390"; #endif - dfo_set(opts->fmt); /* Verbose logging */ opts->verbose = UTIL_LOG_ERROR; util_log_set_level(opts->verbose); @@ -132,8 +130,6 @@ static void __noreturn print_version_exit(const char *prog_name) */ static void fmt_set(struct options *opts, const char *fmt) { - if (dfo_set(fmt) != 0) - ERR_EXIT("Invalid target format \"%s\" specified", fmt); opts->fmt_specified = 1; opts->fmt = fmt; } diff --git a/zdump/zgetdump.c b/zdump/zgetdump.c index 4130e542..fa22338f 100644 --- a/zdump/zgetdump.c +++ b/zdump/zgetdump.c @@ -179,6 +179,9 @@ int main(int argc, char *argv[]) sig_handler_init(); opts_parse(argc, argv, &g.opts); + if (dfo_set(g.opts.fmt) != 0) + ERR_EXIT("Invalid target format \"%s\" specified", g.opts.fmt); + switch (g.opts.action) { case ZG_ACTION_STDOUT: return do_stdout();