diff options
author | Yaniv Kaul <ykaul@redhat.com> | 2018-08-21 18:56:24 +0300 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-08-25 17:10:11 +0000 |
commit | 14ee864f8b573d1bccf4f586450947ba4aa690a9 (patch) | |
tree | ff5f153f1fa229ed018f9f8e3fd3141a07b5709b | |
parent | 7e229cf1d5d4c0600f0763dac3acacb1b950fc3b (diff) |
multiple files: move from strlen() to sizeof()
{ec-heal|ec-combine|ec-helpers|ec-inode-read}.c
For const strings, just do compile time size calc instead of runtime.
Compile-tested only!
Change-Id: If92ba0a7a20f64b898d01c6e3b6708190ca93e04
updates: bz#1193929
Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
-rw-r--r-- | libglusterfs/src/glusterfs.h | 3 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-combine.c | 10 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-heal.c | 2 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-helpers.c | 2 | ||||
-rw-r--r-- | xlators/cluster/ec/src/ec-inode-read.c | 2 |
5 files changed, 11 insertions, 8 deletions
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h index 7dd3b06a468..1fae5e7c1be 100644 --- a/libglusterfs/src/glusterfs.h +++ b/libglusterfs/src/glusterfs.h @@ -90,6 +90,9 @@ #define GLUSTERD_MAX_SNAP_NAME 255 #define GLUSTERFS_SOCKET_LISTEN_BACKLOG 10 + +#define SLEN(str) (sizeof(str) - 1) + #define ZR_MOUNTPOINT_OPT "mountpoint" #define ZR_ATTR_TIMEOUT_OPT "attribute-timeout" #define ZR_ENTRY_TIMEOUT_OPT "entry-timeout" diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c index e4c660d9972..90e004336c0 100644 --- a/xlators/cluster/ec/src/ec-combine.c +++ b/xlators/cluster/ec/src/ec-combine.c @@ -251,9 +251,9 @@ ec_value_ignore (char *key) (strcmp(key, GLUSTERFS_INODELK_COUNT) == 0) || (strcmp(key, GLUSTERFS_ENTRYLK_COUNT) == 0) || (strncmp(key, GF_XATTR_CLRLK_CMD, - strlen (GF_XATTR_CLRLK_CMD)) == 0) || + SLEN (GF_XATTR_CLRLK_CMD)) == 0) || (strcmp(key, DHT_IATT_IN_XDATA_KEY) == 0) || - (strncmp(key, EC_QUOTA_PREFIX, strlen(EC_QUOTA_PREFIX)) == 0) || + (strncmp(key, EC_QUOTA_PREFIX, SLEN (EC_QUOTA_PREFIX)) == 0) || (fnmatch(MARKER_XATTR_PREFIX ".*." XTIME, key, 0) == 0) || (fnmatch(GF_XATTR_MARKER_KEY ".*", key, 0) == 0) || (XATTR_IS_NODE_UUID(key))) { @@ -742,14 +742,14 @@ int32_t ec_dict_data_combine(dict_t * dict, char * key, data_t * value, data->cbk->fop->xl->name); } - if (strncmp(key, GF_XATTR_CLRLK_CMD, strlen(GF_XATTR_CLRLK_CMD)) == 0) + if (strncmp(key, GF_XATTR_CLRLK_CMD, SLEN (GF_XATTR_CLRLK_CMD)) == 0) { return ec_dict_data_concat("{\n}", data->cbk, data->which, key, NULL, NULL, _gf_false); } if (strncmp(key, GF_XATTR_LOCKINFO_KEY, - strlen(GF_XATTR_LOCKINFO_KEY)) == 0) + SLEN (GF_XATTR_LOCKINFO_KEY)) == 0) { return ec_dict_data_merge(data->cbk, data->which, key); } @@ -771,7 +771,7 @@ int32_t ec_dict_data_combine(dict_t * dict, char * key, data_t * value, return ec_dict_data_quota(data->cbk, data->which, key); } /* Ignore all other quota attributes */ - if (strncmp(key, EC_QUOTA_PREFIX, strlen(EC_QUOTA_PREFIX)) == 0) { + if (strncmp(key, EC_QUOTA_PREFIX, SLEN (EC_QUOTA_PREFIX)) == 0) { return 0; } diff --git a/xlators/cluster/ec/src/ec-heal.c b/xlators/cluster/ec/src/ec-heal.c index c16b9c5c4fe..8f57c7c3cd7 100644 --- a/xlators/cluster/ec/src/ec-heal.c +++ b/xlators/cluster/ec/src/ec-heal.c @@ -66,7 +66,7 @@ ec_ignorable_key_match (dict_t *dict, char *key, data_t *val, void *mdata) if (!key) goto out; - if (strncmp (key, EC_XATTR_PREFIX, strlen (EC_XATTR_PREFIX)) == 0) + if (strncmp (key, EC_XATTR_PREFIX, SLEN (EC_XATTR_PREFIX)) == 0) return _gf_true; for (i = 0; ec_ignore_xattrs[i]; i++) { diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c index 83f96ba6cb2..9b833a8d3a4 100644 --- a/xlators/cluster/ec/src/ec-helpers.c +++ b/xlators/cluster/ec/src/ec-helpers.c @@ -821,7 +821,7 @@ gf_boolean_t ec_is_internal_xattr (dict_t *dict, char *key, data_t *value, void *data) { if (key && - (strncmp (key, EC_XATTR_PREFIX, strlen (EC_XATTR_PREFIX)) == 0)) + (strncmp (key, EC_XATTR_PREFIX, SLEN (EC_XATTR_PREFIX)) == 0)) return _gf_true; return _gf_false; diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c index d58ed9e5795..30d76371da6 100644 --- a/xlators/cluster/ec/src/ec-inode-read.c +++ b/xlators/cluster/ec/src/ec-inode-read.c @@ -310,7 +310,7 @@ int32_t ec_manager_getxattr(ec_fop_data_t * fop, int32_t state) to avoid interferences. */ if ((fop->str[0] == NULL) || (strncmp(fop->str[0], GF_XATTR_CLRLK_CMD, - strlen(GF_XATTR_CLRLK_CMD)) != 0)) { + SLEN (GF_XATTR_CLRLK_CMD)) != 0)) { if (fop->fd == NULL) { ec_lock_prepare_inode(fop, &fop->loc[0], EC_QUERY_INFO, 0, LLONG_MAX); |