summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2018-11-08 16:03:23 +0530
committerAtin Mukherjee <amukherj@redhat.com>2018-11-11 15:45:38 +0000
commitdb28fc7a35b784a4ca6a361961081f93e968cfcb (patch)
tree7773a20b5a26a5416eba79dad1888676e666243a /cli/src
parentcefdd02776d204744a13215029f1c3fe024283e4 (diff)
downloadglusterfs-db28fc7a35b784a4ca6a361961081f93e968cfcb.tar.gz
glusterfs-db28fc7a35b784a4ca6a361961081f93e968cfcb.tar.xz
glusterfs-db28fc7a35b784a4ca6a361961081f93e968cfcb.zip
cli: avoid unnecessary strtail for geo rep config.
Found while looking at this function for another patch. Compile Tested Only! Updates bz#1193929 Change-Id: I46a9e95bf4d6609bc122edf86418659369258abe Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/cli/src/cli.c b/cli/src/cli.c
index d17566b670..22b7fb9663 100644
--- a/cli/src/cli.c
+++ b/cli/src/cli.c
@@ -428,7 +428,6 @@ parse_cmdline(int argc, char *argv[], struct cli_state *state)
int i = 0;
int j = 0;
char *opt = NULL;
- gf_boolean_t geo_rep_config = _gf_false;
state->argc = argc - 1;
state->argv = &argv[1];
@@ -442,31 +441,32 @@ parse_cmdline(int argc, char *argv[], struct cli_state *state)
if (state->argc > GEO_REP_CMD_CONFIG_INDEX &&
strtail(state->argv[GEO_REP_CMD_INDEX], "geo") &&
strtail(state->argv[GEO_REP_CMD_CONFIG_INDEX], "co"))
- geo_rep_config = _gf_true;
+ goto done;
for (i = 0; i < state->argc; i++) {
opt = strtail(state->argv[i], "--");
- if (opt && !geo_rep_config) {
- ret = cli_opt_parse(opt, state);
- if (ret == -1) {
- cli_out("unrecognized option --%s", opt);
- return ret;
- } else if (ret == -2) {
- return ret;
- }
- for (j = i; j < state->argc - 1; j++)
- state->argv[j] = state->argv[j + 1];
- state->argc--;
- /* argv shifted, next check should be at i again */
- i--;
- if (ret == 1) {
- /* end of cli options */
- ret = 0;
- break;
- }
+ if (!opt)
+ continue;
+ ret = cli_opt_parse(opt, state);
+ if (ret == -1) {
+ cli_out("unrecognized option --%s", opt);
+ return ret;
+ } else if (ret == -2) {
+ return ret;
+ }
+ for (j = i; j < state->argc - 1; j++)
+ state->argv[j] = state->argv[j + 1];
+ state->argc--;
+ /* argv shifted, next check should be at i again */
+ i--;
+ if (ret == 1) {
+ /* end of cli options */
+ ret = 0;
+ break;
}
}
+done:
state->argv[state->argc] = NULL;
return ret;