mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
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:
committed by
Jan Höppner
parent
df338a3bac
commit
d8871197ea
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user