summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/glusterfs
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2019-04-22 21:34:19 +0300
committerAmar Tumballi <amarts@redhat.com>2019-04-30 06:26:09 +0000
commite6721e1426b116af7460111e8dddd432aea504a2 (patch)
tree3abda29d88924db6ea440faef67dab2b6d42ebe1 /libglusterfs/src/glusterfs
parent5ba81308d58b26f8baff17b44c235d68f88d5f19 (diff)
options.c,h: minor changes to GF_OPTION_RECONF
Minor code changes (less variables and if statements) and use dict_get_strn(), since all options are fixed strings. Similar changes could be done to GF_OPTION_INIT() as well. Change-Id: I4a523f67183f4c4852a3d4de5e3cac52df68d3cf updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'libglusterfs/src/glusterfs')
-rw-r--r--libglusterfs/src/glusterfs/options.h44
1 files changed, 16 insertions, 28 deletions
diff --git a/libglusterfs/src/glusterfs/options.h b/libglusterfs/src/glusterfs/options.h
index 0e683d780df..747b13ba375 100644
--- a/libglusterfs/src/glusterfs/options.h
+++ b/libglusterfs/src/glusterfs/options.h
@@ -264,7 +264,7 @@ DECLARE_INIT_OPT(uint32_t, time);
#define DECLARE_RECONF_OPT(type_t, type) \
int xlator_option_reconf_##type(xlator_t *this, dict_t *options, \
- char *key, type_t *val_p);
+ char *key, int keylen, type_t *val_p);
DECLARE_RECONF_OPT(char *, str);
DECLARE_RECONF_OPT(uint64_t, uint64);
@@ -283,56 +283,44 @@ DECLARE_RECONF_OPT(uint32_t, time);
#define DEFINE_RECONF_OPT(type_t, type, conv) \
int xlator_option_reconf_##type(xlator_t *this, dict_t *options, \
- char *key, type_t *val_p) \
+ char *key, int keylen, type_t *val_p) \
{ \
int ret = 0; \
- volume_option_t *opt = NULL; \
- char *def_value = NULL; \
- char *set_value = NULL; \
char *value = NULL; \
xlator_t *old_THIS = NULL; \
\
- opt = xlator_volume_option_get(this, key); \
+ volume_option_t *opt = xlator_volume_option_get(this, key); \
if (!opt) { \
gf_msg(this->name, GF_LOG_WARNING, EINVAL, LG_MSG_INVALID_ENTRY, \
"unknown option: %s", key); \
- ret = -1; \
- return ret; \
+ return -1; \
} \
- def_value = opt->default_value; \
- ret = dict_get_str(options, key, &set_value); \
- \
- if (def_value) \
- value = def_value; \
- if (set_value) \
- value = set_value; \
- if (!value) { \
- gf_msg_trace(this->name, 0, "option %s not set", key); \
- *val_p = (type_t)0; \
- return 0; \
- } \
- if (value == def_value) { \
+ ret = dict_get_strn(options, key, keylen, &value); \
+ if (ret == 0 && value) { \
+ gf_msg(this->name, GF_LOG_INFO, 0, 0, \
+ "option %s using set value %s", key, value); \
+ } else if (opt->default_value) { \
+ value = opt->default_value; \
gf_msg_trace(this->name, 0, "option %s using default value %s", \
key, value); \
} else { \
- gf_msg(this->name, GF_LOG_INFO, 0, 0, \
- "option %s using set value %s", key, value); \
+ gf_msg_trace(this->name, 0, "option %s not set", key); \
+ *val_p = (type_t)0; \
+ return 0; \
} \
+ \
old_THIS = THIS; \
THIS = this; \
ret = conv(value, val_p); \
THIS = old_THIS; \
if (ret) \
return ret; \
- ret = xlator_option_validate(this, key, value, opt, NULL); \
- return ret; \
+ return xlator_option_validate(this, key, value, opt, NULL); \
}
#define GF_OPTION_RECONF(key, val, opt, type, err_label) \
do { \
- int val_ret = 0; \
- val_ret = xlator_option_reconf_##type(THIS, opt, key, &(val)); \
- if (val_ret) \
+ if (xlator_option_reconf_##type(THIS, opt, key, SLEN(key), &(val))) \
goto err_label; \
} while (0)