aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-device.c
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 /cmds-device.c
parent39b3d7c77a551b7c6b2063789797fceeae22b346 (diff)
downloadbtrfs-progs-4074ae5f2bac71889527e817ddeee5fd85a3ba59.tar.gz
btrfs-progs-4074ae5f2bac71889527e817ddeee5fd85a3ba59.tar.xz
btrfs-progs-4074ae5f2bac71889527e817ddeee5fd85a3ba59.zip
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>
Diffstat (limited to 'cmds-device.c')
-rw-r--r--cmds-device.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/cmds-device.c b/cmds-device.c
index 1c72e90..f9ac7f5 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) {