summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorYaniv Kaul <ykaul@redhat.com>2018-08-02 16:02:33 +0300
committerAmar Tumballi <amarts@redhat.com>2018-08-14 05:15:04 +0000
commitb2b6ab8eff317f6a507ab23897ea6cd5c718d99a (patch)
tree45fb1392f535f0236f057d9d9c932feda4f9ab40 /libglusterfs/src
parent32c8f70f49c0e287c53998e37867f00fa775377b (diff)
All: remove memset() before sprintf()
It's not needed. There's a good chance the compiler is smart enough to remove it anyway, but it can't hurt - I hope. Compile-tested only! Change-Id: Id7c054e146ba630227affa591007803f3046416b updates: bz#1193929 Signed-off-by: Yaniv Kaul <ykaul@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/client_t.c3
-rw-r--r--libglusterfs/src/fd.c8
-rw-r--r--libglusterfs/src/inode.c10
-rw-r--r--libglusterfs/src/stack.c20
-rw-r--r--libglusterfs/src/statedump.c16
5 files changed, 1 insertions, 56 deletions
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c
index e002c1fbed9..aeade5b3a20 100644
--- a/libglusterfs/src/client_t.c
+++ b/libglusterfs/src/client_t.c
@@ -745,7 +745,6 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)
continue;
client = clienttable->cliententries[count].client;
if (!strcmp (client->bound_xl->name, this->name)) {
- memset(key, 0, sizeof (key));
snprintf (key, sizeof (key), "conn%d", count++);
fdtable_dump_to_dict (client->server_ctx.
fdtable,
@@ -864,7 +863,6 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict)
continue;
client = clienttable->cliententries[count].client;
if (!strcmp (client->bound_xl->name, this->name)) {
- memset(key, 0, sizeof (key));
if (client->bound_xl && client->bound_xl->
itable) {
/* Presently every brick contains only
@@ -880,7 +878,6 @@ gf_client_dump_inodes_to_dict (xlator_t *this, dict_t *dict)
continue;
prev_bound_xl = client->bound_xl;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "conn%d",
count);
inode_table_dump_to_dict (client->
diff --git a/libglusterfs/src/fd.c b/libglusterfs/src/fd.c
index 65b23ed3503..01e292cc107 100644
--- a/libglusterfs/src/fd.c
+++ b/libglusterfs/src/fd.c
@@ -1164,19 +1164,16 @@ fdentry_dump_to_dict (fdentry_t *fdentry, char *prefix, dict_t *dict,
return;
if (fdentry->fd) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.pid", prefix);
ret = dict_set_uint64 (dict, key, fdentry->fd->pid);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.refcount", prefix);
ret = dict_set_int32 (dict, key, GF_ATOMIC_GET (fdentry->fd->refcount));
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.flags", prefix);
ret = dict_set_int32 (dict, key, fdentry->fd->flags);
@@ -1202,19 +1199,16 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict)
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.fdtable.refcount", prefix);
ret = dict_set_int32 (dict, key, fdtable->refcount);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.fdtable.maxfds", prefix);
ret = dict_set_uint32 (dict, key, fdtable->max_fds);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.fdtable.firstfree", prefix);
ret = dict_set_int32 (dict, key, fdtable->first_free);
if (ret)
@@ -1223,7 +1217,6 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict)
for (i = 0; i < fdtable->max_fds; i++) {
if (GF_FDENTRY_ALLOCATED ==
fdtable->fdentries[i].next_free) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.fdtable.fdentry%d",
prefix, i);
fdentry_dump_to_dict (&fdtable->fdentries[i], key,
@@ -1231,7 +1224,6 @@ fdtable_dump_to_dict (fdtable_t *fdtable, char *prefix, dict_t *dict)
}
}
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.fdtable.openfds", prefix);
ret = dict_set_int32 (dict, key, openfds);
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c
index b8f1539b2f4..488486f35b8 100644
--- a/libglusterfs/src/inode.c
+++ b/libglusterfs/src/inode.c
@@ -2449,25 +2449,21 @@ inode_dump_to_dict (inode_t *inode, char *prefix, dict_t *dict)
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.gfid", prefix);
ret = dict_set_dynstr (dict, key, gf_strdup (uuid_utoa (inode->gfid)));
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.nlookup", prefix);
ret = dict_set_uint64 (dict, key, inode->nlookup);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.ref", prefix);
ret = dict_set_uint32 (dict, key, inode->ref);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.ia_type", prefix);
ret = dict_set_int32 (dict, key, inode->ia_type);
@@ -2488,26 +2484,22 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict)
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.active_size", prefix);
ret = dict_set_uint32 (dict, key, itable->active_size);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.lru_size", prefix);
ret = dict_set_uint32 (dict, key, itable->lru_size);
if (ret)
goto out;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.purge_size", prefix);
ret = dict_set_uint32 (dict, key, itable->purge_size);
if (ret)
goto out;
list_for_each_entry (inode, &itable->active, list) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.active%d", prefix,
count++);
inode_dump_to_dict (inode, key, dict);
@@ -2515,7 +2507,6 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict)
count = 0;
list_for_each_entry (inode, &itable->lru, list) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.lru%d", prefix,
count++);
inode_dump_to_dict (inode, key, dict);
@@ -2523,7 +2514,6 @@ inode_table_dump_to_dict (inode_table_t *itable, char *prefix, dict_t *dict)
count = 0;
list_for_each_entry (inode, &itable->purge, list) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.itable.purge%d", prefix,
count++);
inode_dump_to_dict (inode, key, dict);
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index 61c779b0453..c4cfebc484a 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(prefix, 0, sizeof(prefix));
memset(&my_frame, 0, sizeof(my_frame));
va_start(ap, key_buf);
vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap);
@@ -169,7 +168,6 @@ gf_proc_dump_call_stack (call_stack_t *call_stack, const char *key_buf,...)
GF_ASSERT (key_buf);
- memset(prefix, 0, sizeof(prefix));
va_start(ap, key_buf);
vsnprintf(prefix, GF_DUMP_MAX_BUF_LEN, key_buf, ap);
va_end(ap);
@@ -267,26 +265,22 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
memcpy (&tmp_frame, call_frame, sizeof (tmp_frame));
UNLOCK (&call_frame->lock);
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.refcount", prefix);
ret = dict_set_int32 (dict, key, tmp_frame.ref_count);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.translator", prefix);
ret = dict_set_dynstr (dict, key, gf_strdup (tmp_frame.this->name));
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.complete", prefix);
ret = dict_set_int32 (dict, key, tmp_frame.complete);
if (ret)
return;
if (tmp_frame.root->ctx->measure_latency) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.timings", prefix);
snprintf (msg, sizeof (msg), "%ld.%"GF_PRI_SNSECONDS
" -> %ld.%"GF_PRI_SNSECONDS,
@@ -298,7 +292,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
}
if (tmp_frame.parent) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.parent", prefix);
ret = dict_set_dynstr (dict, key,
gf_strdup (tmp_frame.parent->this->name));
@@ -307,7 +300,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
}
if (tmp_frame.wind_from) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.windfrom", prefix);
ret = dict_set_dynstr (dict, key,
gf_strdup (tmp_frame.wind_from));
@@ -316,7 +308,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
}
if (tmp_frame.wind_to) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.windto", prefix);
ret = dict_set_dynstr (dict, key,
gf_strdup (tmp_frame.wind_to));
@@ -325,7 +316,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
}
if (tmp_frame.unwind_from) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.unwindfrom", prefix);
ret = dict_set_dynstr (dict, key,
gf_strdup (tmp_frame.unwind_from));
@@ -334,7 +324,6 @@ gf_proc_dump_call_frame_to_dict (call_frame_t *call_frame,
}
if (tmp_frame.unwind_to) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.unwind_to", prefix);
ret = dict_set_dynstr (dict, key,
gf_strdup (tmp_frame.unwind_to));
@@ -357,31 +346,26 @@ gf_proc_dump_call_stack_to_dict (call_stack_t *call_stack,
return;
count = call_frames_count (call_stack);
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.uid", prefix);
ret = dict_set_int32 (dict, key, call_stack->uid);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.gid", prefix);
ret = dict_set_int32 (dict, key, call_stack->gid);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.pid", prefix);
ret = dict_set_int32 (dict, key, call_stack->pid);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.unique", prefix);
ret = dict_set_uint64 (dict, key, call_stack->unique);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.op", prefix);
if (call_stack->type == GF_OP_TYPE_FOP)
ret = dict_set_str (dict, key,
@@ -392,20 +376,17 @@ gf_proc_dump_call_stack_to_dict (call_stack_t *call_stack,
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.type", prefix);
ret = dict_set_int32 (dict, key, call_stack->type);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.count", prefix);
ret = dict_set_int32 (dict, key, count);
if (ret)
return;
list_for_each_entry (trav, &call_stack->myframes, frames) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.frame%d",
prefix, i);
gf_proc_dump_call_frame_to_dict (trav, key, dict);
@@ -439,7 +420,6 @@ gf_proc_dump_pending_frames_to_dict (call_pool_t *call_pool, dict_t *dict)
goto out;
list_for_each_entry (trav, &call_pool->all_frames, all_frames) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "callpool.stack%d", i);
gf_proc_dump_call_stack_to_dict (trav, key, dict);
i++;
diff --git a/libglusterfs/src/statedump.c b/libglusterfs/src/statedump.c
index 21a916ea6b8..d769d7a9ef2 100644
--- a/libglusterfs/src/statedump.c
+++ b/libglusterfs/src/statedump.c
@@ -126,7 +126,6 @@ gf_proc_dump_add_section_fd (char *key, va_list ap)
GF_ASSERT(key);
- memset (buf, 0, sizeof(buf));
snprintf (buf, GF_DUMP_MAX_BUF_LEN, "\n[");
vsnprintf (buf + strlen(buf),
GF_DUMP_MAX_BUF_LEN - strlen (buf), key, ap);
@@ -175,10 +174,7 @@ gf_proc_dump_write_fd (char *key, char *value, va_list ap)
GF_ASSERT (key);
- offset = strlen (key);
-
- memset (buf, 0, GF_DUMP_MAX_BUF_LEN);
- snprintf (buf, GF_DUMP_MAX_BUF_LEN, "%s", key);
+ offset = snprintf (buf, GF_DUMP_MAX_BUF_LEN, "%s", key);
snprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, "=");
offset += 1;
vsnprintf (buf + offset, GF_DUMP_MAX_BUF_LEN - offset, value, ap);
@@ -429,49 +425,41 @@ gf_proc_dump_mempool_info_to_dict (glusterfs_ctx_t *ctx, dict_t *dict)
return;
list_for_each_entry (pool, &ctx->mempool_list, global_list) {
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.name", count);
ret = dict_set_str (dict, key, pool->name);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.hotcount", count);
ret = dict_set_int32 (dict, key, pool->hot_count);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.coldcount", count);
ret = dict_set_int32 (dict, key, pool->cold_count);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.paddedsizeof", count);
ret = dict_set_uint64 (dict, key, pool->padded_sizeof_type);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.alloccount", count);
ret = dict_set_uint64 (dict, key, pool->alloc_count);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.max_alloc", count);
ret = dict_set_int32 (dict, key, pool->max_alloc);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.max-stdalloc", count);
ret = dict_set_int32 (dict, key, pool->max_stdalloc);
if (ret)
return;
- memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "pool%d.pool-misses", count);
ret = dict_set_uint64 (dict, key, pool->pool_misses);
if (ret)
@@ -893,9 +881,7 @@ gf_proc_dump_info (int signum, glusterfs_ctx_t *ctx)
//swallow the errors of write for start and end marker
ret = sys_write (gf_dump_fd, sign_string, strlen (sign_string));
- memset (sign_string, 0, sizeof (sign_string));
memset (timestr, 0, sizeof (timestr));
- memset (&tv, 0, sizeof (tv));
if (GF_PROC_DUMP_IS_OPTION_ENABLED (mem)) {
gf_proc_dump_mem_info ();