diff options
author | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-06 20:23:35 +0200 |
---|---|---|
committer | Xavi Hernandez <xhernandez@redhat.com> | 2018-07-10 16:28:24 +0200 |
commit | 6dc5dfef819cad69d6d4b4c1c305efa74236ad84 (patch) | |
tree | 6b325caf478689d8113279191ca1916e5f5b32ea /xlators/mgmt/glusterd/src/glusterd-volume-ops.c | |
parent | 03f1f5bdc46076178f1afdf8e2a76c5b973fe11f (diff) | |
download | glusterfs-6dc5dfef819cad69d6d4b4c1c305efa74236ad84.tar.gz glusterfs-6dc5dfef819cad69d6d4b4c1c305efa74236ad84.tar.xz glusterfs-6dc5dfef819cad69d6d4b4c1c305efa74236ad84.zip |
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 <xhernandez@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-volume-ops.c')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-ops.c | 64 |
1 files changed, 42 insertions, 22 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c index e46ef57e44..3973a0da78 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-ops.c @@ -1507,6 +1507,7 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, char volid[50] = {0,}; char xattr_volid[50] = {0,}; int caps = 0; + int32_t len = 0; this = THIS; GF_ASSERT (this); @@ -1585,19 +1586,25 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, if (ret && (flags & GF_CLI_FLAG_OP_FORCE)) { continue; } else if (ret) { - snprintf (msg, sizeof (msg), "Failed to find " - "brick directory %s for volume %s. " - "Reason : %s", brickinfo->path, - volname, strerror (errno)); + len = snprintf (msg, sizeof (msg), "Failed to find " + "brick directory %s for volume %s. " + "Reason : %s", brickinfo->path, + volname, strerror (errno)); + if (len < 0) { + strcpy(msg, "<error>"); + } goto out; } ret = sys_lgetxattr (brickinfo->path, GF_XATTR_VOL_ID_KEY, volume_id, 16); if (ret < 0 && (!(flags & GF_CLI_FLAG_OP_FORCE))) { - snprintf (msg, sizeof (msg), "Failed to get " - "extended attribute %s for brick dir %s. " - "Reason : %s", GF_XATTR_VOL_ID_KEY, - brickinfo->path, strerror (errno)); + len = snprintf (msg, sizeof (msg), "Failed to get " + "extended attribute %s for brick dir " + "%s. Reason : %s", GF_XATTR_VOL_ID_KEY, + brickinfo->path, strerror (errno)); + if (len < 0) { + strcpy(msg, "<error>"); + } ret = -1; goto out; } else if (ret < 0) { @@ -1606,22 +1613,30 @@ glusterd_op_stage_start_volume (dict_t *dict, char **op_errstr, volinfo->volume_id, 16, XATTR_CREATE); if (ret == -1) { - snprintf (msg, sizeof (msg), "Failed to set " - "extended attribute %s on %s. Reason: " - "%s", GF_XATTR_VOL_ID_KEY, - brickinfo->path, strerror (errno)); + len = snprintf (msg, sizeof (msg), "Failed to " + "set extended attribute %s on " + "%s. Reason: %s", + GF_XATTR_VOL_ID_KEY, + brickinfo->path, + strerror (errno)); + if (len < 0) { + strcpy(msg, "<error>"); + } goto out; } else { continue; } } if (gf_uuid_compare (volinfo->volume_id, volume_id)) { - snprintf (msg, sizeof (msg), "Volume id mismatch for " - "brick %s:%s. Expected volume id %s, " - "volume id %s found", brickinfo->hostname, - brickinfo->path, - uuid_utoa_r (volinfo->volume_id, volid), - uuid_utoa_r (volume_id, xattr_volid)); + len = snprintf (msg, sizeof (msg), "Volume id " + "mismatch for brick %s:%s. Expected " + "volume id %s, volume id %s found", + brickinfo->hostname, brickinfo->path, + uuid_utoa_r (volinfo->volume_id, volid), + uuid_utoa_r (volume_id, xattr_volid)); + if (len < 0) { + strcpy(msg, "<error>"); + } ret = -1; goto out; } @@ -3070,6 +3085,7 @@ glusterd_clearlocks_get_local_client_ports (glusterd_volinfo_t *volinfo, int ret = -1; int i = 0; int port = 0; + int32_t len = 0; GF_ASSERT (xl_opts); if (!xl_opts) { @@ -3085,11 +3101,15 @@ glusterd_clearlocks_get_local_client_ports (glusterd_volinfo_t *volinfo, continue; if (volinfo->transport_type == GF_TRANSPORT_RDMA) { - snprintf (brickname, sizeof(brickname), "%s.rdma", - brickinfo->path); + len = snprintf (brickname, sizeof(brickname), + "%s.rdma", brickinfo->path); } else - snprintf (brickname, sizeof(brickname), "%s", - brickinfo->path); + len = snprintf (brickname, sizeof(brickname), "%s", + brickinfo->path); + if ((len < 0) || (len >= sizeof(brickname))) { + ret = -1; + goto out; + } port = pmap_registry_search (THIS, brickname, GF_PMAP_PORT_BRICKSERVER, |