summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-24 20:59:30 +0300
committerAmar Tumballi <amarts@redhat.com>2018-08-29 17:31:11 +0000
commitcbe133c832fd9907619a1231aa3d9dda1330ae74 (patch)
treede607cd6daf2e22051da74c848fa569d68131f86
parent789a5a3d3cbad9c594fd2a94924ec0a2040c27ad (diff)
multiple files: remove unndeeded memset()
This is a squash of multiple commits: contrib/fuse-lib/misc.c: remove unneeded memset() All flock variables are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I8e0512c5a88daadb0e587f545fdb9b32ca8858a2 libglusterfs/src/{client_t|fd|inode|stack}.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I2be9ccc3a5cb5da51a92af73488cdabd1c527f59 libglusterfs/src/xlator.c: remove unneeded memset() All xl->mem_acct members are properly set, no need to memset it. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I7f264cd47e7a06255a3f3943c583de77ae8e3147 xlators/cluster/afr/src/afr-self-heal-common.c: remove unneeded memset() Since we are going over the whole array anyway, initialize it properly, to either 1 or 0. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Ied4210388976b6a7a2e91cc3de334534d6fef201 xlators/cluster/dht/src/dht-common.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: Idc436d2bd0563b6582908d7cbebf9dbc66a42c9a xlators/cluster/ec/src/ec-helpers.c: remove unneeded memset() Since we are going over the whole array anyway it is initialized properly. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I81bf971f7fcecb4599e807d37f426f55711978fa xlators/mgmt/glusterd/src/glusterd-volgen.c: remove some memset() I don't think there's a need for any of them. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I476ea59ba53546b5153c269692cd5383da81ce2d xlators/mgmt/glusterd/src/glusterd-geo-rep.c: read() in 4K blocks The current 1K seems small. 4K is usually better (in Linux). Also remove a memset() that I don't think is needed between reads. Only compile-tested! Signed-off-by: Yaniv Kaul <ykaul@redhat.com> Change-Id: I5fb7950c92d282948376db14919ad12e589eac2b xlators/storage/posix/src/posix-{gfid-path|inode-fd-ops}.c: remove memset() before sys_*xattr() functions. I don't see a reason to memset the array sent to the functions sys_llistxattr(), sys_lgetxattr(), sys_lgetxattr(), sys_flistxattr(), sys_fgetxattr(). (Note: it's unclear to me why we are calling sys_*txattr() functions with XATTR_VAL_BUF_SIZE-1 size instead of XATTR_VAL_BUF_SIZE ). Only compile-tested! Change-Id: Ief2103b56ba6c71e40ed343a93684eef6b771346 updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
-rw-r--r--contrib/fuse-lib/misc.c1
-rw-r--r--libglusterfs/src/client_t.c6
-rw-r--r--libglusterfs/src/fd.c2
-rw-r--r--libglusterfs/src/inode.c2
-rw-r--r--libglusterfs/src/stack.c1
-rw-r--r--libglusterfs/src/xlator.c1
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c6
-rw-r--r--xlators/cluster/dht/src/dht-common.c1
-rw-r--r--xlators/cluster/ec/src/ec-helpers.c1
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c11
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volgen.c2
-rw-r--r--xlators/storage/posix/src/posix-gfid-path.c2
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c6
13 files changed, 9 insertions, 33 deletions
diff --git a/contrib/fuse-lib/misc.c b/contrib/fuse-lib/misc.c
index 0c41b1a1917..266bcc75125 100644
--- a/contrib/fuse-lib/misc.c
+++ b/contrib/fuse-lib/misc.c
@@ -41,7 +41,6 @@ void
convert_fuse_file_lock (struct fuse_file_lock *fl, struct gf_flock *flock,
uint64_t lk_owner)
{
- memset (flock, 0, sizeof (struct flock));
flock->l_type = fl->type;
flock->l_whence = SEEK_SET;
flock->l_start = fl->start;
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c
index eb9e7a78b22..844acbc459c 100644
--- a/libglusterfs/src/client_t.c
+++ b/libglusterfs/src/client_t.c
@@ -598,12 +598,9 @@ client_ctx_del (client_t *client, void *key, void **value)
void
client_dump (client_t *client, char *prefix)
{
- char key[GF_DUMP_MAX_BUF_LEN];
-
if (!client)
return;
- memset(key, 0, sizeof key);
gf_proc_dump_write("refcount", GF_PRI_ATOMIC,
GF_ATOMIC_GET (client->count));
}
@@ -641,7 +638,6 @@ clienttable_dump (clienttable_t *clienttable, char *prefix)
"Unable to acquire lock");
return;
}
- memset(key, 0, sizeof key);
gf_proc_dump_build_key(key, prefix, "maxclients");
gf_proc_dump_write(key, "%d", clienttable->max_clients);
gf_proc_dump_build_key(key, prefix, "first_free");
@@ -792,7 +788,6 @@ gf_client_dump_fdtables (xlator_t *this)
clienttable->cliententries[count].next_free)
continue;
client = clienttable->cliententries[count].client;
- memset(key, 0, sizeof key);
if (client->client_uid) {
gf_proc_dump_build_key (key, "conn",
"%d.id", count);
@@ -929,7 +924,6 @@ gf_client_dump_inodes (xlator_t *this)
clienttable->cliententries[count].next_free)
continue;
client = clienttable->cliententries[count].client;
- memset(key, 0, sizeof key);
if (client->bound_xl && client->bound_xl->itable) {
/* Presently every brick contains only
* one bound_xl for all connections.
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 01e292cc107..ee14dc8fe43 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -1032,7 +1032,6 @@ fd_dump (fd_t *fd, char *prefix)
if (!fd)
return;
- memset(key, 0, sizeof(key));
gf_proc_dump_write("pid", "%llu", fd->pid);
gf_proc_dump_write("refcount", "%d", fd->refcount);
gf_proc_dump_write("flags", "%d", fd->flags);
@@ -1074,7 +1073,6 @@ fdtable_dump (fdtable_t *fdtable, char *prefix)
if (ret)
goto out;
- memset(key, 0, sizeof(key));
gf_proc_dump_build_key(key, prefix, "refcount");
gf_proc_dump_write(key, "%d", fdtable->refcount);
gf_proc_dump_build_key(key, prefix, "maxfds");
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index 11814d52d7c..70909bf596f 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -2331,7 +2331,6 @@ inode_dump (inode_t *inode, char *prefix)
if (!inode)
return;
- memset(key, 0, sizeof(key));
INIT_LIST_HEAD (&fd_list);
ret = TRY_LOCK(&inode->lock);
@@ -2406,7 +2405,6 @@ inode_table_dump (inode_table_t *itable, char *prefix)
if (!itable)
return;
- memset(key, 0, sizeof(key));
ret = pthread_mutex_trylock(&itable->lock);
if (ret != 0) {
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 13107e4e3bc..2987441bb6d 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -97,7 +97,6 @@ gf_proc_dump_call_frame (call_frame_t *call_frame, const char *key_buf,...)
GF_ASSERT (key_buf);
- memset(&my_frame, 0, sizeof(my_frame));
va_start(ap, key_buf);
vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap);
va_end(ap);
diff --git a/libglusterfs/src/xlator.c b/libglusterfs/src/xlator.c
index cd71d5fe384..22e3e041fd9 100644
--- a/libglusterfs/src/xlator.c
+++ b/libglusterfs/src/xlator.c
@@ -812,7 +812,6 @@ xlator_mem_acct_init (xlator_t *xl, int num_types)
if (!xl->mem_acct) {
return -1;
}
- memset (xl->mem_acct, 0, sizeof(struct mem_acct));
xl->mem_acct->num_types = num_types;
GF_ATOMIC_INIT (xl->mem_acct->refcnt, 1);
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
index a1aad6315ac..be5dd327c9d 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -851,10 +851,11 @@ afr_mark_active_sinks (xlator_t *this, unsigned char *sources,
priv = this->private;
- memset (sinks, 0, sizeof (*sinks) * priv->child_count);
for (i = 0; i < priv->child_count; i++) {
if (!sources[i] && locked_on[i])
sinks[i] = 1;
+ else
+ sinks[i] = 0;
}
}
@@ -1610,10 +1611,11 @@ afr_selfheal_find_direction (call_frame_t *frame, xlator_t *this,
}
/* Short list all non-accused as sources */
- memset (sources, 0, priv->child_count);
for (i = 0; i < priv->child_count; i++) {
if (!accused[i] && locked_on[i])
sources[i] = 1;
+ else
+ sources[i] = 0;
}
/* Everyone accused by non-self-accused sources are sinks */
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 9ae80b33fe3..d5b41eb9b3b 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1255,7 +1255,6 @@ dht_dict_get_array (dict_t *dict, char *key, int32_t value[], int32_t size, int
return -EINVAL;
}
- memset (value, 0, size * sizeof(int32_t));
for (vindex = 0; vindex < size; vindex++) {
value[vindex] = ntoh32(*((int32_t *)ptr + vindex));
if (value[vindex] < 0)
diff --git a/xlators/cluster/ec/src/ec-helpers.c b/xlators/cluster/ec/src/ec-helpers.c
index 9b833a8d3a4..ff3558def86 100644
--- a/xlators/cluster/ec/src/ec-helpers.c
+++ b/xlators/cluster/ec/src/ec-helpers.c
@@ -232,7 +232,6 @@ ec_dict_get_array (dict_t *dict, char *key, uint64_t value[], int32_t size)
return -EINVAL;
}
- memset (value, 0, size * sizeof(uint64_t));
/* 3.6 version ec would have stored version in 64 bit. In that case treat
* metadata versions same as data*/
old_size = min (size, len/sizeof(uint64_t));
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 7083fb1d339..ac07eb83bd8 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -3848,7 +3848,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
pid_t pid = 0;
char pidfile[PATH_MAX] = {0,};
char errmsg[PATH_MAX] = "";
- char buf [1024] = {0,};
+ char buf [4096] = {0,};
gf_boolean_t is_template_in_use = _gf_false;
char monitor_status[NAME_MAX] = {0,};
char *statefile = NULL;
@@ -3903,7 +3903,7 @@ gd_pause_or_resume_gsync (dict_t *dict, char *master, char *slave,
goto out;
}
- ret = sys_read (pfd, buf, 1024);
+ ret = sys_read (pfd, buf, sizeof (buf));
if (ret > 0) {
pid = strtol (buf, NULL, 10);
if (is_pause) {
@@ -4006,7 +4006,7 @@ stop_gsync (char *master, char *slave, char **msg,
pid_t pid = 0;
char pidfile[PATH_MAX] = {0,};
char errmsg[PATH_MAX] = "";
- char buf[1024] = {0,};
+ char buf[4096] = {0,};
int i = 0;
gf_boolean_t is_template_in_use = _gf_false;
xlator_t *this = NULL;
@@ -4039,7 +4039,7 @@ stop_gsync (char *master, char *slave, char **msg,
if (pfd < 0)
goto out;
- ret = sys_read (pfd, buf, 1024);
+ ret = sys_read (pfd, buf, sizeof (buf));
if (ret > 0) {
pid = strtol (buf, NULL, 10);
ret = kill (-pid, SIGTERM);
@@ -5345,7 +5345,7 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
char *host_uuid = NULL;
char uuid_str [64] = {0};
char *contents = NULL;
- char buf[1024] = "";
+ char buf[4096] = "";
int ret = -1;
int fd = -1;
int bytes_writen = 0;
@@ -5436,7 +5436,6 @@ glusterd_op_copy_file (dict_t *dict, char **op_errstr)
if (ret > 0) {
memcpy (contents+bytes_read, buf, ret);
bytes_read += ret;
- memset (buf, '\0', sizeof(buf));
}
} while (ret > 0);
diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c
index 614ce0eab23..35e49bf56fc 100644
--- a/xlators/mgmt/glusterd/src/glusterd-volgen.c
+++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c
@@ -6121,7 +6121,6 @@ generate_dummy_client_volfiles (glusterd_volinfo_t *volinfo)
if (!dict)
goto out;
for (i = 0; types[i]; i++) {
- memset (filepath, 0, sizeof (filepath));
ret = dict_set_str (dict, "client-transport-type", types[i]);
if (ret)
goto out;
@@ -6195,7 +6194,6 @@ generate_client_volfiles (glusterd_volinfo_t *volinfo,
if (!dict)
goto out;
for (i = 0; types[i]; i++) {
- memset (filepath, 0, sizeof (filepath));
ret = dict_set_str (dict, "client-transport-type", types[i]);
if (ret)
goto out;
diff --git a/xlators/storage/posix/src/posix-gfid-path.c b/xlators/storage/posix/src/posix-gfid-path.c
index 9873e7e5a84..686276eb5a9 100644
--- a/xlators/storage/posix/src/posix-gfid-path.c
+++ b/xlators/storage/posix/src/posix-gfid-path.c
@@ -145,7 +145,6 @@ posix_get_gfid2path (xlator_t *this, inode_t *inode, const char *real_path,
found = _gf_true;
} else {
have_val = _gf_false;
- memset (value_buf, '\0', sizeof(value_buf));
size = sys_llistxattr (real_path, value_buf,
sizeof (value_buf) - 1);
if (size > 0) {
@@ -205,7 +204,6 @@ posix_get_gfid2path (xlator_t *this, inode_t *inode, const char *real_path,
}
found = _gf_true;
- memset (value_buf, '\0', sizeof(value_buf));
size = sys_lgetxattr (real_path, keybuffer, value_buf,
sizeof (value_buf) - 1);
if (size == -1) {
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c
index 1d15801b183..795f19a1515 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -3184,7 +3184,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
}
}
#endif
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
size = sys_lgetxattr (real_path, key, value_buf,
XATTR_VAL_BUF_SIZE-1);
if (size >= 0) {
@@ -3259,7 +3258,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
}
have_val = _gf_false;
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
size = sys_llistxattr (real_path, value_buf, XATTR_VAL_BUF_SIZE-1);
if (size > 0) {
have_val = _gf_true;
@@ -3326,7 +3324,6 @@ posix_getxattr (call_frame_t *frame, xlator_t *this,
goto ignore;
}
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
have_val = _gf_false;
size = sys_lgetxattr (real_path, keybuffer, value_buf,
XATTR_VAL_BUF_SIZE-1);
@@ -3494,7 +3491,6 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
allocate a new buffer value of required size and call getxattr again
*/
value_buf = alloca (XATTR_VAL_BUF_SIZE);
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
if (name) {
strncpy (key, name, sizeof(key));
@@ -3570,7 +3566,6 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
goto done;
}
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
size = sys_flistxattr (_fd, value_buf, XATTR_VAL_BUF_SIZE-1);
if (size > 0) {
have_val = _gf_true;
@@ -3619,7 +3614,6 @@ posix_fgetxattr (call_frame_t *frame, xlator_t *this,
break;
strncpy (key, list + list_offset, sizeof(key));
- memset (value_buf, '\0', XATTR_VAL_BUF_SIZE);
have_val = _gf_false;
size = sys_fgetxattr (_fd, key, value_buf,
XATTR_VAL_BUF_SIZE-1);