diff options
author | Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com> | 2016-05-09 16:49:19 +0900 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-05-11 16:43:41 +0200 |
commit | ad474ff50cdde156135f88b059e1a9b05ae3f239 (patch) | |
tree | 9617b7bd479551bf46ed1872667de53f3f4bbcee | |
parent | b72438362b2dbce880cefe9427ffe0947a94e060 (diff) |
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>
-rw-r--r-- | cmds-property.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/cmds-property.c b/cmds-property.c index 48a8945a..46be8f3b 100644 --- a/cmds-property.c +++ b/cmds-property.c @@ -298,7 +298,7 @@ static void parse_args(int argc, char **argv, { int ret; char *type_str = NULL; - int max_nonopt_args = 0; + int max_nonopt_args = 1; optind = 1; while (1) { @@ -315,8 +315,6 @@ static void parse_args(int argc, char **argv, } } - if (object) - max_nonopt_args++; if (name) max_nonopt_args++; if (value) @@ -345,14 +343,13 @@ static void parse_args(int argc, char **argv, } } - if (object && optind < argc) - *object = argv[optind++]; - if (name && optind < argc) + *object = argv[optind++]; + if (optind < argc) *name = argv[optind++]; - if (value && optind < argc) + if (optind < argc) *value = argv[optind++]; - if (!*types && object && *object) { + if (!*types) { ret = autodetect_object_types(*object, types); if (ret < 0) { error("failed to detect object type: %s", |