zdump/opts: Make command-line argument parsing independent of DFO

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 <egorenar@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
Alexander Egorenkov
2021-10-11 16:13:26 +02:00
committed by Jan Höppner
parent df338a3bac
commit d8871197ea
2 changed files with 3 additions and 4 deletions

View File

@@ -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;
}

View File

@@ -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();