summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-statedump.c
diff options
context:
space:
mode:
authorRavishankar N <ravishankar@redhat.com>2018-08-15 19:34:31 +0530
committerAmar Tumballi <amarts@redhat.com>2018-08-21 10:50:21 +0000
commitcb210f83455e2f659e734dfa09ff7602b5b75201 (patch)
treee355b6545f3d029d7fbd9cc3910bd347a89e567c /xlators/mgmt/glusterd/src/glusterd-statedump.c
parent6fa531c57c633827283fba6a3cdaa1c68976ccb7 (diff)
glusterd: fix gcc warnings
...and also changed char array initialization to from {0,} to "". gcc version 8.1.1 20180712 (Red Hat 8.1.1-5) (GCC) on Fedora 28. Sample warnings: glusterd-utils.c:7234:41: warning: ‘.hostname’ directive output may be truncated writing 9 bytes into a region of size between 1 and 1024 [-Wformat-truncation=] snprintf (key, sizeof (key), "%s.hostname", base_key); ^~~~~~~~~ glusterd-utils.c:7234:9: note: ‘snprintf’ output between 10 and 1033 bytes into a destination of size 1024 snprintf (key, sizeof (key), "%s.hostname", base_key); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glusterd-snapshot.c:3090:65: warning: ‘/’ directive output may be truncated writing 1 byte into a region of size between 0 and 4095 [-Wformat-truncation=] snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", ^ glusterd-snapshot.c:3090:17: note: ‘snprintf’ output between 2 and 4351 bytes into a destination of size 4095 snprintf (snap_path, sizeof (snap_path) - 1, "%s/%s", ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ snap_mount_dir, snap_vol->snapshot->snapname); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ glusterd-statedump.c:28:45: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 144 [-Wformat-truncation=] snprintf (subkey, sizeof (subkey), "%s%d", key, index); ^~ ~~~ glusterd-statedump.c:28:9: note: ‘snprintf’ output between 2 and 4107 bytes into a destination of size 144 snprintf (subkey, sizeof (subkey), "%s%d", key, index); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ updates: bz#1193929 Change-Id: Ic721f27b28d1221c124b570e81c55528f5b7f3cd Signed-off-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-statedump.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-statedump.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-statedump.c b/xlators/mgmt/glusterd/src/glusterd-statedump.c
index a3f12d62ed2..aa866954ecd 100644
--- a/xlators/mgmt/glusterd/src/glusterd-statedump.c
+++ b/xlators/mgmt/glusterd/src/glusterd-statedump.c
@@ -20,8 +20,8 @@ static void
glusterd_dump_peer (glusterd_peerinfo_t *peerinfo, char *input_key, int index,
gf_boolean_t xpeers)
{
- char subkey[144] = {0,};
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char subkey[GF_DUMP_MAX_BUF_LEN + 11] = "";
+ char key[GF_DUMP_MAX_BUF_LEN] = "";
strncpy (key, input_key, sizeof(key) - 1);
@@ -63,9 +63,9 @@ glusterd_dump_peer_rpcstat (glusterd_peerinfo_t *peerinfo, char *input_key,
rpc_clnt_connection_t *conn = NULL;
int ret = -1;
rpc_clnt_t *rpc = NULL;
- char rpcsvc_peername[RPCSVC_PEER_STRLEN] = {0,};
- char subkey[144] = {0,};
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char rpcsvc_peername[RPCSVC_PEER_STRLEN] = "";
+ char subkey[GF_DUMP_MAX_BUF_LEN + 11] = "";
+ char key[GF_DUMP_MAX_BUF_LEN] = "";
strncpy (key, input_key, sizeof(key) - 1);
@@ -106,8 +106,8 @@ static void
glusterd_dump_client_details (glusterd_conf_t *conf)
{
rpc_transport_t *xprt = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
- char subkey[50] = {0,};
+ char key[GF_DUMP_MAX_BUF_LEN] = "";
+ char subkey[50] = "";
int index = 1;
pthread_mutex_lock (&conf->xprt_lock);
@@ -147,8 +147,8 @@ glusterd_dict_mgmt_v3_lock_statedump (dict_t *dict)
int ret = 0;
int dumplen = 0;
data_pair_t *trav = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
- char dump[64*1024] = {0,};
+ char key[GF_DUMP_MAX_BUF_LEN] = "";
+ char dump[64*1024] = "";
if (!dict) {
gf_msg_callingfn ("glusterd", GF_LOG_WARNING, EINVAL,
@@ -186,7 +186,7 @@ int
glusterd_dump_priv (xlator_t *this)
{
glusterd_conf_t *priv = NULL;
- char key[GF_DUMP_MAX_BUF_LEN] = {0,};
+ char key[GF_DUMP_MAX_BUF_LEN] = "";
int port = 0;
struct pmap_registry *pmap = NULL;