From 9647f0c64bfb0af2e4354998d1be672f7101a358 Mon Sep 17 00:00:00 2001 From: Sanju Rakonde Date: Sat, 2 Jun 2018 01:38:10 +0530 Subject: glusterd: Coverity Fixes Fixes: #789278 Change-Id: I633704fab49992cac6ee9e05bc368f7da360d09e Signed-off-by: Sanju Rakonde Signed-off-by: Jiffin Tony Thottan --- xlators/mgmt/glusterd/src/glusterd-op-sm.c | 4 +++- xlators/mgmt/glusterd/src/glusterd-utils.c | 7 ++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index 956cd256c4f..c1e7612c377 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -5979,6 +5979,8 @@ glusterd_op_ac_commit_op (glusterd_op_sm_event_t *event, void *ctx) gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "Failed to set transaction id."); + if (txn_op_info.skip_locking) + ret = glusterd_clear_txn_opinfo (txn_id); GF_FREE (txn_id); goto out; } @@ -5995,7 +5997,7 @@ out: /* for no volname transactions, the txn_opinfo needs to be cleaned up * as there's no unlock event triggered */ - if (txn_op_info.skip_locking) + if (txn_id && txn_op_info.skip_locking) ret = glusterd_clear_txn_opinfo (txn_id); gf_msg_debug (this->name, 0, "Returning with %d", ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 22c23df131e..07987418a7f 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -1254,8 +1254,9 @@ glusterd_brickinfo_new_from_brick (char *brick, ret = gf_canonicalize_path (path); if (ret) goto out; - strncpy (new_brickinfo->hostname, hostname, 1024); - strncpy (new_brickinfo->path, path, 1024); + gf_strncpy (new_brickinfo->hostname, hostname, + sizeof(new_brickinfo->hostname)); + gf_strncpy (new_brickinfo->path, path, sizeof(new_brickinfo->path)); if (construct_real_path) { ret = glusterd_hostname_to_uuid (new_brickinfo->hostname, @@ -7489,7 +7490,7 @@ out: } if (*in_use) { - if (!strcmp (path, curdir)) { + if (path && curdir && !strcmp (path, curdir)) { snprintf (msg, sizeof (msg), "%s is already part of a " "volume", path); } else { -- cgit