summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2015-04-08 17:33:55 +0200
committerDavid Sterba <dsterba@suse.cz>2015-04-08 17:33:55 +0200
commit4074ae5f2bac71889527e817ddeee5fd85a3ba59 (patch)
tree18c6b62da30f57218777a5003356edf51a39fffb
parent39b3d7c77a551b7c6b2063789797fceeae22b346 (diff)
btrfs-progs: cleanup option index argument from getopt_long
We're not using it anywhere. The best practice is to add enums with values > 255 for the long options, option index counting is error prone. Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--btrfs-convert.c4
-rw-r--r--btrfs-corrupt-block.c3
-rw-r--r--btrfs-map-logical.c4
-rw-r--r--cmds-balance.c8
-rw-r--r--cmds-check.c4
-rw-r--r--cmds-device.c17
-rw-r--r--cmds-fi-disk_usage.c6
-rw-r--r--cmds-filesystem.c12
-rw-r--r--cmds-qgroup.c4
-rw-r--r--cmds-restore.c3
-rw-r--r--mkfs.c3
11 files changed, 27 insertions, 41 deletions
diff --git a/btrfs-convert.c b/btrfs-convert.c
index c7ff8280..f9dd7346 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -2838,7 +2838,6 @@ int main(int argc, char *argv[])
char *fslabel = NULL;
while(1) {
- int long_index;
enum { GETOPT_VAL_NO_PROGRESS = 256 };
static const struct option long_options[] = {
{ "no-progress", no_argument, NULL,
@@ -2853,8 +2852,7 @@ int main(int argc, char *argv[])
{ "nodesize", required_argument, NULL, 'N' },
{ NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "dinN:rl:Lp", long_options,
- &long_index);
+ int c = getopt_long(argc, argv, "dinN:rl:Lp", long_options, NULL);
if (c < 0)
break;
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index f332bdf7..56b553d2 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -1017,7 +1017,6 @@ int main(int ac, char **av)
while(1) {
int c;
- int option_index = 0;
static const struct option long_options[] = {
/* { "byte-count", 1, NULL, 'b' }, */
{ "logical", 1, NULL, 'l' },
@@ -1041,7 +1040,7 @@ int main(int ac, char **av)
};
c = getopt_long(ac, av, "l:c:b:eEkuUi:f:x:m:K:IDdr:",
- long_options, &option_index);
+ long_options, NULL);
if (c < 0)
break;
switch(c) {
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index fc8ce46f..5d14035e 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -124,7 +124,6 @@ int main(int ac, char **av)
while(1) {
int c;
- int option_index = 0;
static const struct option long_options[] = {
/* { "byte-count", 1, NULL, 'b' }, */
{ "logical", 1, NULL, 'l' },
@@ -134,8 +133,7 @@ int main(int ac, char **av)
{ NULL, 0, NULL, 0}
};
- c = getopt_long(ac, av, "l:c:o:b:", long_options,
- &option_index);
+ c = getopt_long(ac, av, "l:c:o:b:", long_options, NULL);
if (c < 0)
break;
switch(c) {
diff --git a/cmds-balance.c b/cmds-balance.c
index 367ab554..92a15335 100644
--- a/cmds-balance.c
+++ b/cmds-balance.c
@@ -389,7 +389,6 @@ static int cmd_balance_start(int argc, char **argv)
optind = 1;
while (1) {
- int longindex;
static const struct option longopts[] = {
{ "data", optional_argument, NULL, 'd'},
{ "metadata", optional_argument, NULL, 'm' },
@@ -399,8 +398,7 @@ static int cmd_balance_start(int argc, char **argv)
{ NULL, 0, NULL, 0 }
};
- int opt = getopt_long(argc, argv, "d::s::m::fv", longopts,
- &longindex);
+ int opt = getopt_long(argc, argv, "d::s::m::fv", longopts, NULL);
if (opt < 0)
break;
@@ -661,13 +659,13 @@ static int cmd_balance_status(int argc, char **argv)
optind = 1;
while (1) {
- int longindex;
+ int opt;
static const struct option longopts[] = {
{ "verbose", no_argument, NULL, 'v' },
{ NULL, 0, NULL, 0 }
};
- int opt = getopt_long(argc, argv, "v", longopts, &longindex);
+ opt = getopt_long(argc, argv, "v", longopts, NULL);
if (opt < 0)
break;
diff --git a/cmds-check.c b/cmds-check.c
index ed8c6984..d5cb94f9 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -9221,7 +9221,6 @@ int cmd_check(int argc, char **argv)
while(1) {
int c;
- int option_index = 0;
enum { OPT_REPAIR = 257, OPT_INIT_CSUM, OPT_INIT_EXTENT,
OPT_CHECK_CSUM, OPT_READONLY };
static const struct option long_options[] = {
@@ -9238,8 +9237,7 @@ int cmd_check(int argc, char **argv)
{ NULL, 0, NULL, 0}
};
- c = getopt_long(argc, argv, "as:br:", long_options,
- &option_index);
+ c = getopt_long(argc, argv, "as:br:", long_options, NULL);
if (c < 0)
break;
switch(c) {
diff --git a/cmds-device.c b/cmds-device.c
index 1c72e90b..f9ac7f5f 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -55,14 +55,14 @@ static int cmd_add_dev(int argc, char **argv)
char estr[100];
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "nodiscard", optional_argument, NULL, 'K'},
{ "force", no_argument, NULL, 'f'},
{ NULL, 0, NULL, 0}
};
- int c = getopt_long(argc, argv, "Kf", long_options,
- &long_index);
+
+ c = getopt_long(argc, argv, "Kf", long_options, NULL);
if (c < 0)
break;
switch (c) {
@@ -213,13 +213,13 @@ static int cmd_scan_dev(int argc, char **argv)
optind = 1;
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "all-devices", no_argument, NULL, 'd'},
{ NULL, 0, NULL, 0}
};
- int c = getopt_long(argc, argv, "d", long_options,
- &long_index);
+
+ c = getopt_long(argc, argv, "d", long_options, NULL);
if (c < 0)
break;
switch (c) {
@@ -503,7 +503,7 @@ int cmd_device_usage(int argc, char **argv)
optind = 1;
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "raw", no_argument, NULL, 'b'},
{ "kbytes", no_argument, NULL, 'k'},
@@ -516,9 +516,8 @@ int cmd_device_usage(int argc, char **argv)
GETOPT_VAL_HUMAN_READABLE},
{ NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "bhHkmgt", long_options,
- &long_index);
+ c = getopt_long(argc, argv, "bhHkmgt", long_options, NULL);
if (c < 0)
break;
switch (c) {
diff --git a/cmds-fi-disk_usage.c b/cmds-fi-disk_usage.c
index 27b989df..06f3d06e 100644
--- a/cmds-fi-disk_usage.c
+++ b/cmds-fi-disk_usage.c
@@ -882,7 +882,7 @@ int cmd_filesystem_usage(int argc, char **argv)
optind = 1;
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "raw", no_argument, NULL, 'b'},
{ "kbytes", no_argument, NULL, 'k'},
@@ -895,8 +895,8 @@ int cmd_filesystem_usage(int argc, char **argv)
GETOPT_VAL_HUMAN_READABLE},
{ NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "bhHkmgtT", long_options,
- &long_index);
+
+ c = getopt_long(argc, argv, "bhHkmgtT", long_options, NULL);
if (c < 0)
break;
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index f3fc160c..188dbf0c 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -208,7 +208,7 @@ static int cmd_filesystem_df(int argc, char **argv)
unsigned unit_mode = UNITS_DEFAULT;
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "raw", no_argument, NULL, 'b'},
{ "kbytes", no_argument, NULL, 'k'},
@@ -221,8 +221,8 @@ static int cmd_filesystem_df(int argc, char **argv)
GETOPT_VAL_HUMAN_READABLE},
{ NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "bhHkmgt", long_options,
- &long_index);
+
+ c = getopt_long(argc, argv, "bhHkmgt", long_options, NULL);
if (c < 0)
break;
switch (c) {
@@ -836,14 +836,14 @@ static int cmd_show(int argc, char **argv)
int found = 0;
while (1) {
- int long_index;
+ int c;
static const struct option long_options[] = {
{ "all-devices", no_argument, NULL, 'd'},
{ "mounted", no_argument, NULL, 'm'},
{ NULL, 0, NULL, 0 }
};
- int c = getopt_long(argc, argv, "dm", long_options,
- &long_index);
+
+ c = getopt_long(argc, argv, "dm", long_options, NULL);
if (c < 0)
break;
switch (c) {
diff --git a/cmds-qgroup.c b/cmds-qgroup.c
index 2d6d84b8..b1c7e181 100644
--- a/cmds-qgroup.c
+++ b/cmds-qgroup.c
@@ -251,7 +251,6 @@ static int cmd_qgroup_show(int argc, char **argv)
optind = 1;
while (1) {
int c;
- int option_index = 0;
static const struct option long_options[] = {
{"sort", 1, NULL, 'S'},
{"raw", no_argument, NULL, GETOPT_VAL_RAW},
@@ -265,9 +264,8 @@ static int cmd_qgroup_show(int argc, char **argv)
GETOPT_VAL_HUMAN_READABLE},
{ NULL, 0, NULL, 0 }
};
- c = getopt_long(argc, argv, "pcreFf",
- long_options, &option_index);
+ c = getopt_long(argc, argv, "pcreFf", long_options, NULL);
if (c < 0)
break;
switch (c) {
diff --git a/cmds-restore.c b/cmds-restore.c
index d2caa6ac..21e58eba 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -1176,7 +1176,6 @@ int cmd_restore(int argc, char **argv)
while (1) {
int opt;
- int option_index = 0;
static const struct option long_options[] = {
{ "path-regex", 1, NULL, 256},
{ "dry-run", 0, NULL, 'D'},
@@ -1184,7 +1183,7 @@ int cmd_restore(int argc, char **argv)
};
opt = getopt_long(argc, argv, "sxviot:u:df:r:lDc", long_options,
- &option_index);
+ NULL);
if (opt < 0)
break;
diff --git a/mkfs.c b/mkfs.c
index 8eab0e59..e8ee071c 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -1142,7 +1142,6 @@ int main(int ac, char **av)
while(1) {
int c;
- int option_index = 0;
static const struct option long_options[] = {
{ "alloc-start", 1, NULL, 'A'},
{ "byte-count", 1, NULL, 'b' },
@@ -1163,7 +1162,7 @@ int main(int ac, char **av)
};
c = getopt_long(ac, av, "A:b:fl:n:s:m:d:L:O:r:U:VMK",
- long_options, &option_index);
+ long_options, NULL);
if (c < 0)
break;
switch(c) {