diff options
author | Pranith Kumar K <pkarampu@redhat.com> | 2012-11-08 15:41:55 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2012-11-08 10:37:55 -0500 |
commit | 23b959642a7cddd02bd1bf867d504ec95764efcb (patch) | |
tree | 1e9a02d46b32e047ae0ba3a96c041f7c6dda91b6 | |
parent | 30153d0b9d52e2643bdea858dc71ee1aa2a3dba5 (diff) |
mgmt/glusterd: Remove inner function to prevent execstack marking
Change-Id: I1f318fb4388ee3499e3bfab5c8f8f6c837a7d934
BUG: 840122
Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/1512
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Tested-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index 18652bb877b..eba534af443 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -275,6 +275,30 @@ out: return ret; } +struct args_pack { + dict_t *dict; + int vol_count; + int opt_count; +}; + +static void +_build_option_key (dict_t *d, char *k, data_t *v, void *tmp) +{ + char reconfig_key[256] = {0, }; + struct args_pack *pack = NULL; + int ret = -1; + + if (strcmp (k, GLUSTERD_GLOBAL_OPT_VERSION) == 0) + return; + pack = tmp; + snprintf (reconfig_key, 256, "volume%d.option.%s", + pack->vol_count, k); + ret = dict_set_str (pack->dict, reconfig_key, v->data); + if (0 == ret) + pack->opt_count++; + + return; +} int glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, @@ -286,12 +310,11 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo = NULL; char *buf = NULL; int i = 1; - char reconfig_key[256] = {0, }; dict_t *dict = NULL; - int opt_count = 0; glusterd_conf_t *priv = NULL; char *volume_id_str = NULL; xlator_t *this = NULL; + struct args_pack pack = {0,}; GF_ASSERT (volinfo); @@ -374,21 +397,14 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, goto out; } - void _build_option_key (dict_t *d, char *k, data_t *v, void *tmp) - { - if (strcmp (k, GLUSTERD_GLOBAL_OPT_VERSION) == 0) - return; - snprintf (reconfig_key, 256, "volume%d.option.%s", count, k); - ret = dict_set_str (volumes, reconfig_key, v->data); - if (0 == ret) - opt_count++; - return; - } - dict_foreach (dict, _build_option_key, NULL); - dict_foreach (priv->opts, _build_option_key, NULL); + pack.dict = volumes; + pack.vol_count = count; + pack.opt_count = 0; + dict_foreach (dict, _build_option_key, &pack); + dict_foreach (priv->opts, _build_option_key, &pack); - snprintf (key, 256, "volume%d.opt_count", count); - ret = dict_set_int32 (volumes, key, opt_count); + snprintf (key, 256, "volume%d.opt_count", pack.vol_count); + ret = dict_set_int32 (volumes, key, pack.opt_count); out: return ret; } |