summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-21 19:18:17 +0300
committerAmar Tumballi <amarts@redhat.com>2018-08-29 06:09:10 +0000
commit8d171374cbbbdd88c8714198903b317bd132e1e2 (patch)
treeb10e6fd5ba8b79d41e79c2d22757a5d3e82576a4
parent60ef38482cc8d61711ecc48159cf6c036b1522a8 (diff)
multiple files: move from strlen() to sizeof()
{glusterfsd|glusterfsd-mgmt|quota-common-utils|xlator|tier|stripe}.c tools/setgfid2path/src/main.c xlators/cluster/afr/src/afr-inode-read.c {glusterfs-acl|glusterfs}.h For const strings, just do compile time size calc instead of runtime. Compile-tested only! Change-Id: I303684b1ff29b05c10126fb1057f507e404ced07 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
-rw-r--r--glusterfsd/src/glusterfsd-mgmt.c4
-rw-r--r--glusterfsd/src/glusterfsd.c2
-rw-r--r--libglusterfs/src/glusterfs-acl.h8
-rw-r--r--libglusterfs/src/glusterfs.h8
-rw-r--r--libglusterfs/src/quota-common-utils.c4
-rw-r--r--libglusterfs/src/xlator.c2
-rw-r--r--tools/setgfid2path/src/main.c2
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c14
-rw-r--r--xlators/cluster/dht/src/tier.c2
-rw-r--r--xlators/cluster/stripe/src/stripe.c4
10 files changed, 24 insertions, 26 deletions
diff --git a/glusterfsd/src/glusterfsd-mgmt.c b/glusterfsd/src/glusterfsd-mgmt.c
index 3228c27c6aa..8b25f3a1525 100644
--- a/glusterfsd/src/glusterfsd-mgmt.c
+++ b/glusterfsd/src/glusterfsd-mgmt.c
@@ -826,10 +826,10 @@ glusterfs_handle_bitrot (rpcsvc_request_t *req)
goto out;
}
- if (!strncmp (scrub_opt, "status", strlen ("status"))) {
+ if (!strncmp (scrub_opt, "status", SLEN ("status"))) {
ret = xlator->notify (xlator, GF_EVENT_SCRUB_STATUS, input,
output);
- } else if (!strncmp (scrub_opt, "ondemand", strlen ("ondemand"))) {
+ } else if (!strncmp (scrub_opt, "ondemand", SLEN ("ondemand"))) {
ret = xlator->notify (xlator, GF_EVENT_SCRUB_ONDEMAND, input,
output);
if (ret == -2) {
diff --git a/glusterfsd/src/glusterfsd.c b/glusterfsd/src/glusterfsd.c
index 5497f592ea6..81a73344d6b 100644
--- a/glusterfsd/src/glusterfsd.c
+++ b/glusterfsd/src/glusterfsd.c
@@ -2143,7 +2143,7 @@ parse_cmdline (int argc, char *argv[], glusterfs_ctx_t *ctx)
}
if (cmd_args->thin_client) {
- len = strlen (cmd_args->volfile_id) + strlen ("gfproxy-client/");
+ len = strlen (cmd_args->volfile_id) + SLEN ("gfproxy-client/");
thin_volfileid = GF_CALLOC (1, len + 1, gf_common_mt_char);
snprintf (thin_volfileid, len + 1, "gfproxy-client/%s",
cmd_args->volfile_id);
diff --git a/libglusterfs/src/glusterfs-acl.h b/libglusterfs/src/glusterfs-acl.h
index 2a1661686bc..6194f320ab0 100644
--- a/libglusterfs/src/glusterfs-acl.h
+++ b/libglusterfs/src/glusterfs-acl.h
@@ -120,8 +120,8 @@ struct posix_acl_conf {
#define GF_POSIX_ACL_ACCESS "glusterfs.posix.acl"
#define GF_POSIX_ACL_DEFAULT "glusterfs.posix.default_acl"
#define GF_POSIX_ACL_REQUEST(key) \
- (!strncmp(key, GF_POSIX_ACL_ACCESS, strlen(GF_POSIX_ACL_ACCESS)) || \
- !strncmp(key, GF_POSIX_ACL_DEFAULT, strlen(GF_POSIX_ACL_DEFAULT)))
+ (!strncmp(key, GF_POSIX_ACL_ACCESS, SLEN (GF_POSIX_ACL_ACCESS)) || \
+ !strncmp(key, GF_POSIX_ACL_DEFAULT, SLEN (GF_POSIX_ACL_DEFAULT)))
#ifdef HAVE_SYS_ACL_H /* only NetBSD does not support POSIX ACLs */
@@ -151,10 +151,10 @@ gf_posix_acl_get_type (const char *key)
{
acl_type_t type = 0;
- if (!strncmp (key, GF_POSIX_ACL_ACCESS, strlen (GF_POSIX_ACL_ACCESS)))
+ if (!strncmp (key, GF_POSIX_ACL_ACCESS, SLEN (GF_POSIX_ACL_ACCESS)))
type = ACL_TYPE_ACCESS;
else if (!strncmp (key, GF_POSIX_ACL_DEFAULT,
- strlen (GF_POSIX_ACL_DEFAULT)))
+ SLEN (GF_POSIX_ACL_DEFAULT)))
type = ACL_TYPE_DEFAULT;
else
errno = EINVAL;
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 1fae5e7c1be..423804300a3 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -130,13 +130,13 @@
(strncmp (x, GF_XATTR_USER_PATHINFO_KEY, \
strlen (x)) == 0))
#define XATTR_IS_NODE_UUID(x) (strncmp (x, GF_XATTR_NODE_UUID_KEY, \
- strlen (GF_XATTR_NODE_UUID_KEY)) == 0)
+ SLEN (GF_XATTR_NODE_UUID_KEY)) == 0)
#define XATTR_IS_NODE_UUID_LIST(x) (strncmp (x, GF_XATTR_LIST_NODE_UUIDS_KEY, \
- strlen (GF_XATTR_LIST_NODE_UUIDS_KEY)) == 0)
+ SLEN (GF_XATTR_LIST_NODE_UUIDS_KEY)) == 0)
#define XATTR_IS_LOCKINFO(x) (strncmp (x, GF_XATTR_LOCKINFO_KEY, \
- strlen (GF_XATTR_LOCKINFO_KEY)) == 0)
+ SLEN (GF_XATTR_LOCKINFO_KEY)) == 0)
-#define XATTR_IS_BD(x) (strncmp (x, BD_XATTR_KEY, strlen (BD_XATTR_KEY)) == 0)
+#define XATTR_IS_BD(x) (strncmp (x, BD_XATTR_KEY, SLEN (BD_XATTR_KEY)) == 0)
#define GF_XATTR_LINKINFO_KEY "trusted.distribute.linkinfo"
#define GFID_XATTR_KEY "trusted.gfid"
diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c
index 623248f2eb6..a0a7dd5aafe 100644
--- a/libglusterfs/src/quota-common-utils.c
+++ b/libglusterfs/src/quota-common-utils.c
@@ -140,10 +140,8 @@ out:
int32_t
quota_conf_read_header (int fd, char *buf)
{
- int header_len = 0;
int ret = 0;
-
- header_len = strlen (QUOTA_CONF_HEADER);
+ const int header_len = SLEN (QUOTA_CONF_HEADER);
ret = gf_nread (fd, buf, header_len);
if (ret <= 0) {
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index b1a79a68bf5..cd71d5fe384 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -481,7 +481,7 @@ xlator_set_type (xlator_t *xl, const char *type)
/* Handle 'global' translator differently */
if (!strncmp (GF_GLOBAL_XLATOR_NAME, type,
- strlen (GF_GLOBAL_XLATOR_NAME))) {
+ SLEN (GF_GLOBAL_XLATOR_NAME))) {
volume_opt_list_t *vol_opt = NULL;
/* set the required values from Global xlator */
diff --git a/tools/setgfid2path/src/main.c b/tools/setgfid2path/src/main.c
index 07d7a48b15d..dfa561f4f51 100644
--- a/tools/setgfid2path/src/main.c
+++ b/tools/setgfid2path/src/main.c
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
xxh64
);
- key_size = strlen(GFID2PATH_XATTR_KEY_PREFIX) +
+ key_size = SLEN (GFID2PATH_XATTR_KEY_PREFIX) +
GF_XXH64_DIGEST_LENGTH*2+1;
key = alloca (key_size);
snprintf (key, key_size, GFID2PATH_XATTR_KEY_PREFIX"%s", xxh64);
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index e8192a2b753..350d0325470 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -435,7 +435,7 @@ __gather_xattr_keys (dict_t *dict, char *key, data_t *value,
struct _xattr_key * xkey = NULL;
if (!strncmp (key, AFR_XATTR_PREFIX,
- strlen (AFR_XATTR_PREFIX))) {
+ SLEN (AFR_XATTR_PREFIX))) {
xkey = GF_CALLOC (1, sizeof (*xkey), gf_afr_mt_xattr_key);
if (!xkey)
@@ -814,7 +814,7 @@ unlock:
/*Since we store the UUID0_STR as node uuid for down bricks and
*for non zero op_ret, assigning length to priv->child_count
*number of uuids*/
- local->cont.getxattr.xattr_len = (strlen (UUID0_STR) + 2) *
+ local->cont.getxattr.xattr_len = (SLEN (UUID0_STR) + 2) *
priv->child_count;
if (!local->dict)
@@ -1214,7 +1214,7 @@ unlock:
/* extra bytes for decorations (brackets and <>'s) */
padding += strlen (this->name)
- + strlen (AFR_PATHINFO_HEADER) + 4;
+ + SLEN (AFR_PATHINFO_HEADER) + 4;
local->cont.getxattr.xattr_len += (padding + 2);
xattr_serz = GF_CALLOC (local->cont.getxattr.xattr_len,
@@ -1339,7 +1339,7 @@ unlock:
goto unwind;
/* extra bytes for decorations (brackets and <>'s) */
- padding += strlen (this->name) + strlen (AFR_PATHINFO_HEADER) + 4;
+ padding += strlen (this->name) + SLEN (AFR_PATHINFO_HEADER) + 4;
local->cont.getxattr.xattr_len += (padding + 2);
xattr_serz = GF_CALLOC (local->cont.getxattr.xattr_len,
@@ -1460,14 +1460,14 @@ afr_is_special_xattr (const char *name, fop_getxattr_cbk_t *cbk,
*cbk = afr_getxattr_pathinfo_cbk;
}
} else if (!strncmp (name, GF_XATTR_CLRLK_CMD,
- strlen (GF_XATTR_CLRLK_CMD))) {
+ SLEN (GF_XATTR_CLRLK_CMD))) {
if (is_fgetxattr) {
*cbk = afr_fgetxattr_clrlk_cbk;
} else {
*cbk = afr_getxattr_clrlk_cbk;
}
} else if (!strncmp (name, GF_XATTR_LOCKINFO_KEY,
- strlen (GF_XATTR_LOCKINFO_KEY))) {
+ SLEN (GF_XATTR_LOCKINFO_KEY))) {
if (is_fgetxattr) {
*cbk = afr_fgetxattr_lockinfo_cbk;
} else {
@@ -1633,7 +1633,7 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
}
if (!strncmp (name, AFR_XATTR_PREFIX,
- strlen (AFR_XATTR_PREFIX))) {
+ SLEN (AFR_XATTR_PREFIX))) {
op_errno = ENODATA;
goto out;
}
diff --git a/xlators/cluster/dht/src/tier.c b/xlators/cluster/dht/src/tier.c
index fd57ddfaaab..13ce7f4fb2b 100644
--- a/xlators/cluster/dht/src/tier.c
+++ b/xlators/cluster/dht/src/tier.c
@@ -1583,7 +1583,7 @@ tier_process_brick (tier_brick_list_t *local_brick, void *args) {
goto out;
}
- if (strval && (strncmp(strval, "wal", strlen ("wal")) == 0)) {
+ if (strval && (strncmp(strval, "wal", SLEN ("wal")) == 0)) {
ret = tier_process_self_query (local_brick, args);
if (ret) {
goto out;
diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c
index ae84757bb50..75851aa6c5d 100644
--- a/xlators/cluster/stripe/src/stripe.c
+++ b/xlators/cluster/stripe/src/stripe.c
@@ -5528,7 +5528,7 @@ stripe_getxattr (call_frame_t *frame, xlator_t *this,
if (name && strncmp (name, QUOTA_SIZE_KEY,
- strlen (QUOTA_SIZE_KEY)) == 0) {
+ SLEN (QUOTA_SIZE_KEY)) == 0) {
local->wind_count = priv->child_count;
for (i = 0, trav=this->children; i < priv->child_count; i++,
@@ -5596,7 +5596,7 @@ stripe_is_special_xattr (const char *name)
}
if (!strncmp (name, GF_XATTR_LOCKINFO_KEY,
- strlen (GF_XATTR_LOCKINFO_KEY))
+ SLEN (GF_XATTR_LOCKINFO_KEY))
|| XATTR_IS_PATHINFO (name))
is_spl = _gf_true;
out: