From ecbf1339a63e99a8ef7d5ddc334e38a39f291d3d Mon Sep 17 00:00:00 2001 From: David Sterba Date: Mon, 19 Jan 2015 13:30:06 +0100 Subject: btrfs-progs: cleanup, move getop long options close to their use Move long_option defintions just before getopt_long everywhere. Signed-off-by: David Sterba --- cmds-restore.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'cmds-restore.c') diff --git a/cmds-restore.c b/cmds-restore.c index 859deaf3..795332db 100644 --- a/cmds-restore.c +++ b/cmds-restore.c @@ -1122,12 +1122,6 @@ out: return ret; } -static struct option long_options[] = { - { "path-regex", 1, NULL, 256}, - { "dry-run", 0, NULL, 'D'}, - { NULL, 0, NULL, 0} -}; - const char * const cmd_restore_usage[] = { "btrfs restore [options] | -l ", "Try to restore files from a damaged filesystem (unmounted)", @@ -1162,8 +1156,6 @@ int cmd_restore(int argc, char **argv) u64 root_objectid = 0; int len; int ret; - int opt; - int option_index = 0; int super_mirror = 0; int find_dir = 0; int list_roots = 0; @@ -1172,8 +1164,19 @@ int cmd_restore(int argc, char **argv) regex_t match_reg, *mreg = NULL; char reg_err[256]; - while ((opt = getopt_long(argc, argv, "sxviot:u:df:r:lDc", long_options, - &option_index)) != -1) { + while (1) { + int opt; + int option_index = 0; + static struct option long_options[] = { + { "path-regex", 1, NULL, 256}, + { "dry-run", 0, NULL, 'D'}, + { NULL, 0, NULL, 0} + }; + + opt = getopt_long(argc, argv, "sxviot:u:df:r:lDc", long_options, + &option_index); + if (opt < 0) + break; switch (opt) { case 's': -- cgit v1.2.3