summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/options.c
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2012-06-14 11:53:48 +0530
committerAnand Avati <avati@redhat.com>2012-06-19 23:52:14 -0700
commitc7974318f09ed720471a02f3ec72569d4d7bbdfa (patch)
tree09151b4caa5255805fb4a2051de3b0717106048f /libglusterfs/src/options.c
parent79aa6092a277975cb618d89da645080e51958543 (diff)
libglusterfs: Fix sizet validation for cache-size
Validation of 'cache-size' option will not fail when given value is greater than max. Values lesser than min will cause validation to fail. Change-Id: I9c744b5ace10604d5a814e6218ca0d83c796db80 BUG: 831568 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.com/3570 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'libglusterfs/src/options.c')
-rw-r--r--libglusterfs/src/options.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/libglusterfs/src/options.c b/libglusterfs/src/options.c
index e5025e45ef3..76e581fddb7 100644
--- a/libglusterfs/src/options.c
+++ b/libglusterfs/src/options.c
@@ -120,7 +120,7 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
volume_option_t *opt, char **op_errstr)
{
uint64_t size = 0;
- int ret = -1;
+ int ret = 0;
char errstr[256];
/* Check the range */
@@ -129,6 +129,7 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
"invalid number format \"%s\" in option \"%s\"",
value, key);
gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
+ ret = -1;
goto out;
}
@@ -136,29 +137,26 @@ xlator_option_validate_sizet (xlator_t *xl, const char *key, const char *value,
gf_log (xl->name, GF_LOG_TRACE,
"no range check required for 'option %s %s'",
key, value);
- ret = 0;
goto out;
}
if ((size < opt->min) || (size > opt->max)) {
- if (strncmp (key, "cache-size", 10) == 0) {
+ if ((strncmp (key, "cache-size", 10) == 0) &&
+ (size > opt->max)) {
snprintf (errstr, 256, "Cache size %"PRId64" is out of "
"range [%"PRId64" - %"PRId64"]",
size, opt->min, opt->max);
gf_log (xl->name, GF_LOG_WARNING, "%s", errstr);
- ret = 0;
- goto out;
} else {
snprintf (errstr, 256,
"'%"PRId64"' in 'option %s %s' "
"is out of range [%"PRId64" - %"PRId64"]",
size, key, value, opt->min, opt->max);
gf_log (xl->name, GF_LOG_ERROR, "%s", errstr);
- goto out;
+ ret = -1;
}
}
- ret = 0;
out:
if (ret && op_errstr)
*op_errstr = gf_strdup (errstr);