summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSachin Pandit <spandit@redhat.com>2013-11-05 17:29:17 +0000
committerSachin Pandit <spandit@redhat.com>2013-11-06 12:01:05 +0000
commit7966b9cc4149b490a932919c38d43a4b4373e2ea (patch)
tree8fc30281702702ba1933d997ce76ec516c8a1156
parent533d29e5d2d5afc80f927d1f37dce3bd352a5efd (diff)
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 <spandit@redhat.com>
-rw-r--r--cli/src/cli-cmd-parser.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index d576e1133..9c4face47 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -2640,8 +2640,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;
@@ -2703,30 +2704,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 */
@@ -2738,7 +2741,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 */
@@ -2900,7 +2903,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;