btrfs-progs: Avoid use pointer in handle_options

We use pointer of argc and argv in handle_options() because they
are necessary in very old code which are not exist now.

This patch move to use argc and argv directly in handle_options(),
alone with following update:
1: rename handle_options() to check_options()
   to fit its function.
2: cleanup for condition in handle_options() to make line short.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Zhao Lei 2015-10-29 17:31:48 +08:00 committed by David Sterba
parent eccf7aa62e
commit c9bddcacbc

16
btrfs.c
View File

@ -172,20 +172,24 @@ static int cmd_version(int argc, char **argv)
return 0; return 0;
} }
static void handle_options(int *argc, char ***argv) static void check_options(int argc, char **argv)
{ {
if (*argc > 0) { const char *arg;
const char *arg = (*argv)[0];
if (argc == 0)
return;
arg = argv[0];
if (arg[0] != '-' || if (arg[0] != '-' ||
!strcmp(arg, "--help") || !strcmp(arg, "--help") ||
!strcmp(arg, "--version")) !strcmp(arg, "--version"))
return; return;
fprintf(stderr, "Unknown option: %s\n", arg); fprintf(stderr, "Unknown option: %s\n", arg);
fprintf(stderr, "usage: %s\n", fprintf(stderr, "usage: %s\n",
btrfs_cmd_group.usagestr[0]); btrfs_cmd_group.usagestr[0]);
exit(129); exit(129);
}
return;
} }
static const struct cmd_group btrfs_cmd_group = { static const struct cmd_group btrfs_cmd_group = {
@ -227,7 +231,7 @@ int main(int argc, char **argv)
} else { } else {
argc--; argc--;
argv++; argv++;
handle_options(&argc, &argv); check_options(argc, argv);
if (argc > 0) { if (argc > 0) {
if (!prefixcmp(argv[0], "--")) if (!prefixcmp(argv[0], "--"))
argv[0] += 2; argv[0] += 2;