diff options
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r-- | cli/src/cli-cmd-parser.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index 2b0633eeb..4bbaa4923 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -2736,8 +2736,9 @@ out: } int32_t -cli_snap_create_desc_parse (dict_t *dict, const char **words, int wordcount, - int32_t desc_opt_loc, int32_t no_of_wrds_in_desc) +cli_snap_create_desc_parse (dict_t *dict, const char **words, + int wordcount, int32_t desc_opt_loc, + unsigned int no_of_wrds_in_desc) { int32_t ret = -1; char *desc = NULL; @@ -2799,30 +2800,32 @@ int32_t cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, unsigned int cmdi) { - int32_t volcount = -1; - int32_t no_of_wrds_in_desc = -1; - int32_t name_opt_loc = -1; - int32_t desc_opt_loc = -1; + unsigned int volcount = 0; + unsigned int no_of_wrds_in_desc = 0; + unsigned int name_opt_loc = 0; + unsigned int desc_opt_loc = 0; char volname_buf[PATH_MAX] = ""; int32_t ret = -1; - int32_t i = -1; + int32_t i = 0; + + GF_ASSERT (cmdi > 0); /* Finding the "-n" and "-d" in the cli */ for (i = cmdi + 1; i < wordcount; i++) { if ((strcmp (words[i], "-n") == 0) && - (name_opt_loc == -1)) + (name_opt_loc == 0)) name_opt_loc = i; if ((strcmp (words[i], "-d") == 0) && - (desc_opt_loc == -1)) + (desc_opt_loc == 0)) desc_opt_loc = i; } - if ((name_opt_loc == -1) && (desc_opt_loc == -1)) { + if ((name_opt_loc == 0) && (desc_opt_loc == 0)) { /* No snap-name and description has been given */ volcount = (wordcount - 1) - cmdi; - } else if ((name_opt_loc > cmdi + 1) && (desc_opt_loc == -1)) { + } else if ((name_opt_loc > cmdi + 1) && (desc_opt_loc == 0)) { /* If only name and no description is given */ /* if more than one or no snap name is given */ @@ -2834,7 +2837,7 @@ cli_snap_create_parse (dict_t *dict, const char **words, int wordcount, } volcount = (name_opt_loc - 1) - cmdi; - } else if ((name_opt_loc == -1) && (desc_opt_loc > cmdi + 1)) { + } else if ((name_opt_loc == 0) && (desc_opt_loc > cmdi + 1)) { /* If no name and only description is given */ /* Description should not be blank */ @@ -2997,7 +3000,8 @@ out : * command, here cmdi is 2 i.e "gluster snapshot list" */ int -cli_snap_list_parse (dict_t *dict, const char **words, int wordcount, int cmdi) +cli_snap_list_parse (dict_t *dict, const char **words, int wordcount, + unsigned int cmdi) { int ret = -1; int loop_ret = -1; |