mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-25 04:16:32 +00:00
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>
This commit is contained in:
parent
39b3d7c77a
commit
4074ae5f2b
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
3
mkfs.c
3
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user