summaryrefslogtreecommitdiffstats
path: root/xlators/features
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2018-09-28 13:03:38 +0530
committerAmar Tumballi <amarts@redhat.com>2018-10-15 04:05:30 +0000
commit76cc1ea613e038ced4bc6ae26233cb0681b63be5 (patch)
treeecca8321697c25951dbe94bb4b7d182040d567ac /xlators/features
parentc962e2cbd73e78f31e690f7b1f8456616006c543 (diff)
libglusterfs/dict: Add sizeof()-1 variants of dict functions
One needs to be very careful about giving same key for the key and SLEN(key) arguments in dict_xxxn() functions. Writing macros that would take care of passing the SLEN(key) would help reduce this burden on the developer and reviewer. updates: bz#1193929 Change-Id: I312c479b919826570b47ae2c219c53e2f9b2ddef Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
Diffstat (limited to 'xlators/features')
-rw-r--r--xlators/features/quota/src/quota-enforcer-client.c19
-rw-r--r--xlators/features/quota/src/quota.c3
-rw-r--r--xlators/features/quota/src/quota.h3
-rw-r--r--xlators/features/quota/src/quotad-aggregator.c14
4 files changed, 13 insertions, 26 deletions
diff --git a/xlators/features/quota/src/quota-enforcer-client.c b/xlators/features/quota/src/quota-enforcer-client.c
index d69bc919e23..1a4c2e30dd6 100644
--- a/xlators/features/quota/src/quota-enforcer-client.c
+++ b/xlators/features/quota/src/quota-enforcer-client.c
@@ -395,8 +395,7 @@ quota_enforcer_blocking_connect(rpc_clnt_t *rpc)
if (options == NULL)
goto out;
- ret = dict_set_nstrn(options, "non-blocking-io", SLEN("non-blocking-io"),
- "no", SLEN("no"));
+ ret = dict_set_sizen_str_sizen(options, "non-blocking-io", "no");
if (ret)
goto out;
@@ -404,8 +403,7 @@ quota_enforcer_blocking_connect(rpc_clnt_t *rpc)
rpc_clnt_start(rpc);
- ret = dict_set_nstrn(options, "non-blocking-io", SLEN("non-blocking-io"),
- "yes", SLEN("yes"));
+ ret = dict_set_sizen_str_sizen(options, "non-blocking-io", "yes");
if (ret)
goto out;
@@ -444,21 +442,16 @@ quota_enforcer_init(xlator_t *this, dict_t *options)
priv->quota_enforcer = &quota_enforcer_clnt;
- ret = dict_set_nstrn(options, "transport.address-family",
- SLEN("transport.address-family"), "unix",
- SLEN("unix"));
+ ret = dict_set_sizen_str_sizen(options, "transport.address-family", "unix");
if (ret)
goto out;
- ret = dict_set_nstrn(options, "transport-type", SLEN("transport-type"),
- "socket", SLEN("socket"));
+ ret = dict_set_sizen_str_sizen(options, "transport-type", "socket");
if (ret)
goto out;
- ret = dict_set_nstrn(options, "transport.socket.connect-path",
- SLEN("transport.socket.connect-path"),
- "/var/run/gluster/quotad.socket",
- SLEN("/var/run/gluster/quotad.socket"));
+ ret = dict_set_sizen_str_sizen(options, "transport.socket.connect-path",
+ "/var/run/gluster/quotad.socket");
if (ret)
goto out;
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 8015e8aae8b..6310967fc0d 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -3967,8 +3967,7 @@ quota_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,
VALIDATE_OR_GOTO(this, err);
VALIDATE_OR_GOTO(loc, err);
- if (xdata && dict_getn(xdata, GLUSTERFS_INTERNAL_FOP_KEY,
- SLEN(GLUSTERFS_INTERNAL_FOP_KEY)))
+ if (xdata && dict_get_sizen(xdata, GLUSTERFS_INTERNAL_FOP_KEY))
internal_fop = _gf_true;
if (frame->root->pid >= 0 && internal_fop == _gf_false) {
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
index f0a5d4ed279..8bcc3ec6176 100644
--- a/xlators/features/quota/src/quota.h
+++ b/xlators/features/quota/src/quota.h
@@ -47,8 +47,7 @@
#define QUOTA_WIND_FOR_INTERNAL_FOP(xdata, label) \
do { \
- if (xdata && dict_getn(xdata, GLUSTERFS_INTERNAL_FOP_KEY, \
- SLEN(GLUSTERFS_INTERNAL_FOP_KEY))) \
+ if (xdata && dict_get_sizen(xdata, GLUSTERFS_INTERNAL_FOP_KEY)) \
goto label; \
} while (0)
diff --git a/xlators/features/quota/src/quotad-aggregator.c b/xlators/features/quota/src/quotad-aggregator.c
index 288955034bd..e0129e4f63a 100644
--- a/xlators/features/quota/src/quotad-aggregator.c
+++ b/xlators/features/quota/src/quotad-aggregator.c
@@ -142,7 +142,7 @@ quotad_aggregator_getlimit_cbk(xlator_t *this, call_frame_t *frame,
if (ret < 0)
goto out;
- ret = dict_set_int32n(xdata, "type", SLEN("type"), type);
+ ret = dict_set_int32_sizen(xdata, "type", type);
if (ret < 0)
goto out;
}
@@ -234,26 +234,22 @@ quotad_aggregator_getlimit(rpcsvc_request_t *req)
state = frame->root->state;
state->xdata = dict;
- ret = dict_set_int32n(state->xdata, QUOTA_LIMIT_KEY, SLEN(QUOTA_LIMIT_KEY),
- 42);
+ ret = dict_set_int32_sizen(state->xdata, QUOTA_LIMIT_KEY, 42);
if (ret)
goto err;
- ret = dict_set_int32n(state->xdata, QUOTA_LIMIT_OBJECTS_KEY,
- SLEN(QUOTA_LIMIT_OBJECTS_KEY), 42);
+ ret = dict_set_int32_sizen(state->xdata, QUOTA_LIMIT_OBJECTS_KEY, 42);
if (ret) {
gf_msg(this->name, GF_LOG_ERROR, ENOMEM, Q_MSG_ENOMEM,
"Failed to set QUOTA_LIMIT_OBJECTS_KEY");
goto err;
}
- ret = dict_set_int32n(state->xdata, QUOTA_SIZE_KEY, SLEN(QUOTA_SIZE_KEY),
- 42);
+ ret = dict_set_int32_sizen(state->xdata, QUOTA_SIZE_KEY, 42);
if (ret)
goto err;
- ret = dict_set_int32n(state->xdata, GET_ANCESTRY_PATH_KEY,
- SLEN(GET_ANCESTRY_PATH_KEY), 42);
+ ret = dict_set_int32_sizen(state->xdata, GET_ANCESTRY_PATH_KEY, 42);
if (ret)
goto err;