From 8537ebec13e6a84568f75e35851e43a76c70abaf Mon Sep 17 00:00:00 2001 From: Sachin Pandit Date: Tue, 5 Nov 2013 17:29:17 +0000 Subject: cli/snapshot : Changed the type of few variables. Minor changes to the type of few varaibles was required as comparison between "unsigned int" and "int" in "snap create parse" was leading to incorrect result. The default snapshot name should be time stamp, instead of that "snapshot" was getting assigned as a snapshot name. This patch also fixes the default snapshot name problem. Change-Id: I5b48444059bc400717b35647edec08a444bcfc48 Signed-off-by: Sachin Pandit --- cli/src/cli-cmd-parser.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'cli/src') 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; -- cgit