[sheepdog] [PATCH] sheep: refine the object cache size value range

Liu Yuan namei.unix at gmail.com
Wed Sep 26 08:11:13 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

sys->object_cache_size is uint32, we shouldn't use -1 to indicate invalid value.
Instead, we allow 1 to UINT32_MAX inclusive by using 0 to indicate invalid value

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 sheep/sheep.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sheep/sheep.c b/sheep/sheep.c
index 7fa8249..4f42745 100644
--- a/sheep/sheep.c
+++ b/sheep/sheep.c
@@ -208,7 +208,7 @@ static void object_cache_size_set(char *s)
 
 err:
 	fprintf(stderr, "Invalid object cache option '%s': "
-		"size must be an integer between 0 and %"PRIu32"\n",
+		"size must be an integer between 1 and %"PRIu32" inclusive\n",
 		s, max_cache_size);
 	exit(1);
 }
@@ -295,11 +295,11 @@ static void do_cache_type(char *s)
 
 static void init_cache_type(char *arg)
 {
-	sys->object_cache_size = -1;
+	sys->object_cache_size = 0;
 
 	parse_arg(arg, ",", do_cache_type);
 
-	if (is_object_cache_enabled() && sys->object_cache_size == -1) {
+	if (is_object_cache_enabled() && sys->object_cache_size == 0) {
 		fprintf(stderr, "object cache size is not set\n");
 		exit(1);
 	}
-- 
1.7.10.2




More information about the sheepdog mailing list