mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-11 00:09:49 +00:00
btrfs-progs: prop: simplify parse_args()
Since <object> parameter is mandatory for all subcommands, 'object' is always set by parse_args()'s callers. In addition, on setting '*name' and '*value', if 'optind < argc' is satisfied here, they are always set by parse_args()'s callers. Signed-off-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
b72438362b
commit
ad474ff50c
@ -298,7 +298,7 @@ static void parse_args(int argc, char **argv,
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *type_str = NULL;
|
char *type_str = NULL;
|
||||||
int max_nonopt_args = 0;
|
int max_nonopt_args = 1;
|
||||||
|
|
||||||
optind = 1;
|
optind = 1;
|
||||||
while (1) {
|
while (1) {
|
||||||
@ -315,8 +315,6 @@ static void parse_args(int argc, char **argv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object)
|
|
||||||
max_nonopt_args++;
|
|
||||||
if (name)
|
if (name)
|
||||||
max_nonopt_args++;
|
max_nonopt_args++;
|
||||||
if (value)
|
if (value)
|
||||||
@ -345,14 +343,13 @@ static void parse_args(int argc, char **argv,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (object && optind < argc)
|
*object = argv[optind++];
|
||||||
*object = argv[optind++];
|
if (optind < argc)
|
||||||
if (name && optind < argc)
|
|
||||||
*name = argv[optind++];
|
*name = argv[optind++];
|
||||||
if (value && optind < argc)
|
if (optind < argc)
|
||||||
*value = argv[optind++];
|
*value = argv[optind++];
|
||||||
|
|
||||||
if (!*types && object && *object) {
|
if (!*types) {
|
||||||
ret = autodetect_object_types(*object, types);
|
ret = autodetect_object_types(*object, types);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
error("failed to detect object type: %s",
|
error("failed to detect object type: %s",
|
||||||
|
Loading…
Reference in New Issue
Block a user