From f551548372efa9a22a34e4f1b74fa794d304e6f5 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Wed, 13 Jul 2016 19:41:55 +0200 Subject: [PATCH] btrfs-progs: do not set optind if not necessary In the subcommand callbacks that are called just once, we don't need to explicitly reset optind. Signed-off-by: David Sterba --- btrfstune.c | 1 - cmds-balance.c | 2 -- cmds-device.c | 2 -- cmds-fi-du.c | 1 - cmds-fi-usage.c | 1 - cmds-filesystem.c | 1 - cmds-inspect.c | 2 -- cmds-qgroup.c | 2 -- cmds-quota.c | 1 - cmds-scrub.c | 2 -- cmds-subvolume.c | 5 ----- 11 files changed, 20 deletions(-) diff --git a/btrfstune.c b/btrfstune.c index f731e3d..ac559fb 100644 --- a/btrfstune.c +++ b/btrfstune.c @@ -399,7 +399,6 @@ int main(int argc, char *argv[]) int ret; u64 super_flags = 0; - optind = 1; while(1) { static const struct option long_options[] = { { "help", no_argument, NULL, GETOPT_VAL_HELP}, diff --git a/cmds-balance.c b/cmds-balance.c index 7181673..374e981 100644 --- a/cmds-balance.c +++ b/cmds-balance.c @@ -522,7 +522,6 @@ static int cmd_balance_start(int argc, char **argv) memset(&args, 0, sizeof(args)); - optind = 1; while (1) { enum { GETOPT_VAL_FULL_BALANCE = 256 }; static const struct option longopts[] = { @@ -785,7 +784,6 @@ static int cmd_balance_status(int argc, char **argv) int verbose = 0; int ret; - optind = 1; while (1) { int opt; static const struct option longopts[] = { diff --git a/cmds-device.c b/cmds-device.c index 1c886ad..59695fe 100644 --- a/cmds-device.c +++ b/cmds-device.c @@ -257,7 +257,6 @@ static int cmd_device_scan(int argc, char **argv) int all = 0; int ret = 0; - optind = 1; while (1) { int c; static const struct option long_options[] = { @@ -392,7 +391,6 @@ static int cmd_device_stats(int argc, char **argv) __u64 flags = 0; DIR *dirstream = NULL; - optind = 1; while ((c = getopt(argc, argv, "z")) != -1) { switch (c) { case 'z': diff --git a/cmds-fi-du.c b/cmds-fi-du.c index 6d5bf35..ec8e550 100644 --- a/cmds-fi-du.c +++ b/cmds-fi-du.c @@ -543,7 +543,6 @@ int cmd_filesystem_du(int argc, char **argv) unit_mode = get_unit_mode_from_arg(&argc, argv, 1); - optind = 1; while (1) { static const struct option long_options[] = { { "summarize", no_argument, NULL, 's'}, diff --git a/cmds-fi-usage.c b/cmds-fi-usage.c index b26ece1..04d68b1 100644 --- a/cmds-fi-usage.c +++ b/cmds-fi-usage.c @@ -922,7 +922,6 @@ int cmd_filesystem_usage(int argc, char **argv) unit_mode = get_unit_mode_from_arg(&argc, argv, 1); - optind = 1; while (1) { int c; diff --git a/cmds-filesystem.c b/cmds-filesystem.c index 9392a30..ef1f550 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -1041,7 +1041,6 @@ static int cmd_filesystem_defrag(int argc, char **argv) defrag_global_verbose = 0; defrag_global_errors = 0; defrag_global_fancy_ioctl = 0; - optind = 1; while(1) { int c = getopt(argc, argv, "vrc::fs:l:t:"); if (c < 0) diff --git a/cmds-inspect.c b/cmds-inspect.c index 2ae44be..4b7cea0 100644 --- a/cmds-inspect.c +++ b/cmds-inspect.c @@ -96,7 +96,6 @@ static int cmd_inspect_inode_resolve(int argc, char **argv) int ret; DIR *dirstream = NULL; - optind = 1; while (1) { int c = getopt(argc, argv, "v"); if (c < 0) @@ -151,7 +150,6 @@ static int cmd_inspect_logical_resolve(int argc, char **argv) char *path_ptr; DIR *dirstream = NULL; - optind = 1; while (1) { int c = getopt(argc, argv, "Pvs:"); if (c < 0) diff --git a/cmds-qgroup.c b/cmds-qgroup.c index 14418d4..a3bc939 100644 --- a/cmds-qgroup.c +++ b/cmds-qgroup.c @@ -309,7 +309,6 @@ static int cmd_qgroup_show(int argc, char **argv) unit_mode = get_unit_mode_from_arg(&argc, argv, 0); - optind = 1; while (1) { int c; static const struct option long_options[] = { @@ -408,7 +407,6 @@ static int cmd_qgroup_limit(int argc, char **argv) int exclusive = 0; DIR *dirstream = NULL; - optind = 1; while (1) { int c = getopt(argc, argv, "ce"); if (c < 0) diff --git a/cmds-quota.c b/cmds-quota.c index 568482f..75c032b 100644 --- a/cmds-quota.c +++ b/cmds-quota.c @@ -120,7 +120,6 @@ static int cmd_quota_rescan(int argc, char **argv) DIR *dirstream = NULL; int wait_for_completion = 0; - optind = 1; while (1) { int c = getopt(argc, argv, "sw"); if (c < 0) diff --git a/cmds-scrub.c b/cmds-scrub.c index 4a1d475..c03bc5f 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1141,7 +1141,6 @@ static int scrub_start(int argc, char **argv, int resume) int force = 0; int nothing_to_resume = 0; - optind = 1; while ((c = getopt(argc, argv, "BdqrRc:n:f")) != -1) { switch (c) { case 'B': @@ -1675,7 +1674,6 @@ static int cmd_scrub_status(int argc, char **argv) int err = 0; DIR *dirstream = NULL; - optind = 1; while ((c = getopt(argc, argv, "dR")) != -1) { switch (c) { case 'd': diff --git a/cmds-subvolume.c b/cmds-subvolume.c index e3d2cbc..be2d41e 100644 --- a/cmds-subvolume.c +++ b/cmds-subvolume.c @@ -127,7 +127,6 @@ static int cmd_subvol_create(int argc, char **argv) struct btrfs_qgroup_inherit *inherit = NULL; DIR *dirstream = NULL; - optind = 1; while (1) { int c = getopt(argc, argv, "c:i:v"); if (c < 0) @@ -263,7 +262,6 @@ static int cmd_subvol_delete(int argc, char **argv) int verbose = 0; int commit_mode = 0; - optind = 1; while (1) { int c; static const struct option long_options[] = { @@ -439,7 +437,6 @@ static int cmd_subvol_list(int argc, char **argv) filter_set = btrfs_list_alloc_filter_set(); comparer_set = btrfs_list_alloc_comparer_set(); - optind = 1; while(1) { int c; static const struct option long_options[] = { @@ -616,7 +613,6 @@ static int cmd_subvol_snapshot(int argc, char **argv) struct btrfs_qgroup_inherit *inherit = NULL; DIR *dirstream1 = NULL, *dirstream2 = NULL; - optind = 1; memset(&args, 0, sizeof(args)); while (1) { int c = getopt(argc, argv, "c:i:r"); @@ -1186,7 +1182,6 @@ static int cmd_subvol_sync(int argc, char **argv) int id_count; int sleep_interval = 1; - optind = 1; while (1) { int c = getopt(argc, argv, "s:"); -- 2.7.4