From 6dc5dfef819cad69d6d4b4c1c305efa74236ad84 Mon Sep 17 00:00:00 2001 From: Xavi Hernandez Date: Fri, 6 Jul 2018 20:23:35 +0200 Subject: Fix compile warnings This patch fixes compile warnings that appear with newer compilers. The solution applied is only to remove the warnings, but it doesn't always solve the problem in the best way. It assumes that the problem will never happen, as the previous code assumed. Change-Id: I6e8470d6c2e2dbd3bd7d324b5fd2f92ffdc3d6ec updates: bz#1193929 Signed-off-by: Xavi Hernandez --- xlators/mgmt/glusterd/src/glusterd-handler.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'xlators/mgmt/glusterd/src/glusterd-handler.c') diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index dd81887ed1f..b59d3819d95 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -471,6 +471,7 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, struct args_pack pack = {0,}; xlator_t *this = NULL; GF_UNUSED int caps = 0; + int32_t len = 0; GF_ASSERT (volinfo); GF_ASSERT (volumes); @@ -654,8 +655,12 @@ glusterd_add_volume_detail_to_dict (glusterd_volinfo_t *volinfo, char brick[1024] = {0,}; char brick_uuid[64] = {0,}; snprintf (key, 256, "volume%d.brick%d", count, i); - snprintf (brick, 1024, "%s:%s", brickinfo->hostname, - brickinfo->path); + len = snprintf (brick, 1024, "%s:%s", brickinfo->hostname, + brickinfo->path); + if ((len < 0) || (len >= 1024)) { + ret = -1; + goto out; + } buf = gf_strdup (brick); ret = dict_set_dynstr (volumes, key, buf); if (ret) -- cgit