Skip to content

Commit

Permalink
Show help when no or an invalid device is given
Browse files Browse the repository at this point in the history
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
  • Loading branch information
Jon Derrick committed Jun 15, 2017
1 parent b633be6 commit 514e1d0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion argconfig.c
Expand Up @@ -119,7 +119,7 @@ static void show_option(const struct argconfig_commandline_options *option)
fprintf(stderr, "\n");
}

static void argconfig_print_help(const char *program_desc,
void argconfig_print_help(const char *program_desc,
const struct argconfig_commandline_options *options)
{
const struct argconfig_commandline_options *s;
Expand Down
2 changes: 2 additions & 0 deletions argconfig.h
Expand Up @@ -78,6 +78,8 @@ extern "C" {

typedef void argconfig_help_func();
void argconfig_append_usage(const char *str);
void argconfig_print_help(const char *program_desc,
const struct argconfig_commandline_options *options);
int argconfig_parse(int argc, char *argv[], const char *program_desc,
const struct argconfig_commandline_options *options,
void *config_out, size_t config_size);
Expand Down
10 changes: 6 additions & 4 deletions nvme.c
Expand Up @@ -135,10 +135,8 @@ static int get_dev(int argc, char **argv)
int ret;

ret = check_arg_dev(argc, argv);
if (ret) {
fprintf(stderr, "expected nvme device (ex: /dev/nvme0), none provided\n");
if (ret)
return ret;
}

return open_dev((const char *)argv[optind]);
}
Expand All @@ -152,7 +150,11 @@ int parse_and_open(int argc, char **argv, const char *desc,
if (ret)
return ret;

return get_dev(argc, argv);
ret = get_dev(argc, argv);
if (ret < 0)
argconfig_print_help(desc, clo);

return ret;
}

static const char *output_format = "Output format: normal|json|binary";
Expand Down

0 comments on commit 514e1d0

Please sign in to comment.