summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-cmd-parser.c
diff options
context:
space:
mode:
authorshishir gowda <shishirng@gluster.com>2011-03-31 04:56:10 +0000
committerVijay Bellur <vijay@dev.gluster.com>2011-03-31 05:04:36 -0700
commit58974b02b6ebb65ee1f7baf23b0fe6c3e7fcf8cd (patch)
tree20cfa527ff37e8a6b2a17aa871e2f0bdca939db2 /cli/src/cli-cmd-parser.c
parent3b5195cfa4976e1d83646b70b0f08f583a7a1094 (diff)
TOP: handle list-cnt behaviour uniformly.
Valid range is 0-100. if list-cnt is 0 or there are no files in the list, handle it uniformly. Signed-off-by: shishir gowda <shishirng@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 2622 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2622
Diffstat (limited to 'cli/src/cli-cmd-parser.c')
-rw-r--r--cli/src/cli-cmd-parser.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 66e5643fcb9..69f95653d2a 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1253,7 +1253,7 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
int ret = -1;
gf1_cli_stats_op op = GF_CLI_STATS_NONE;
gf1_cli_top_op top_op = GF_CLI_TOP_NONE;
- int32_t list_cnt = 0;
+ int32_t list_cnt = -1;
int index = 0;
int perf = 0;
int32_t blk_size = 0;
@@ -1332,15 +1332,11 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
} else if (!strcmp (key, "list-cnt")) {
list_cnt = atoi(value);
- if (!list_cnt) {
- list_cnt = 100;
- }
- if (list_cnt < 1 || list_cnt > 100) {
- cli_out ("list-cnt should be between 1 to 100");
+ if (list_cnt < 0 || list_cnt > 100) {
+ cli_out ("list-cnt should be between 0 to 100");
ret = -1;
goto out;
}
- ret = dict_set_int32 (dict, "list-cnt", list_cnt);
} else if (perf && !strcmp (key, "bs")){
blk_size = atoi (value);
if (blk_size < 0){
@@ -1369,6 +1365,14 @@ cli_cmd_volume_top_parse (const char **words, int wordcount,
goto out;
}
}
+ if (list_cnt == -1)
+ list_cnt = 100;
+ ret = dict_set_int32 (dict, "list-cnt", list_cnt);
+ if (ret) {
+ gf_log ("", GF_LOG_WARNING, "Dict set failed for list_cnt");
+ goto out;
+ }
+
*options = dict;
out:
if (ret && dict)