diff options
author | Prashanth Pai <ppai@redhat.com> | 2017-11-03 11:53:12 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2017-11-06 03:56:48 +0000 |
commit | f461d75b226a5bc6c088280e43a96f9b54f33af5 (patch) | |
tree | 9c743476a35a85777f79c183c65363a1d184697b /xlators | |
parent | 0f10b1a5caa78d723b3e8b879d1de162730913ce (diff) |
glusterd: Fix few coverity errors
Fixes issues 810, 248, 491, 499, 85, 786, 811, 43, and 44
from the report at [1].
[1]: https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-10-30-9aa574a5/html/
BUG: 789278
Change-Id: I27ebae2ffb2256b8eef0757d768cc46e5a942e9f
Signed-off-by: Prashanth Pai <ppai@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c | 7 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-locks.c | 4 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-log-ops.c | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-server-quorum.c | 22 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-sm.c | 5 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.c | 6 |
6 files changed, 34 insertions, 11 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c index a3b0829d942..4ebc823619d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c +++ b/xlators/mgmt/glusterd/src/glusterd-gfproxyd-svc.c @@ -239,8 +239,11 @@ glusterd_gfproxydsvc_manager (glusterd_svc_t *svc, void *data, int flags) out: if (ret) { - gf_event (EVENT_SVC_MANAGER_FAILED, "volume=%s;svc_name=%s", - volinfo->volname, svc->name); + if (volinfo) { + gf_event (EVENT_SVC_MANAGER_FAILED, + "volume=%s;svc_name=%s", + volinfo->volname, svc->name); + } } gf_msg_debug ("glusterd", 0, "Returning %d", ret); diff --git a/xlators/mgmt/glusterd/src/glusterd-locks.c b/xlators/mgmt/glusterd/src/glusterd-locks.c index c7951b3cf24..45667be1894 100644 --- a/xlators/mgmt/glusterd/src/glusterd-locks.c +++ b/xlators/mgmt/glusterd/src/glusterd-locks.c @@ -699,6 +699,7 @@ glusterd_mgmt_v3_lock (const char *name, uuid_t uuid, uint32_t *op_errno, ret = 0; out: + GF_FREE (key_dup); gf_msg_trace (this->name, 0, "Returning %d", ret); return ret; } @@ -753,11 +754,10 @@ gd_mgmt_v3_unlock_timer_cbk (void *data) gf_msg (this->name, GF_LOG_ERROR, 0, GD_MSG_DICT_SET_FAILED, "Unable to get lock owner in mgmt_v3 lock"); - goto out; } out: - if (mgmt_lock_timer->timer) { + if (mgmt_lock_timer && mgmt_lock_timer->timer) { mgmt_lock_timer_xl = mgmt_lock_timer->xl; GF_VALIDATE_OR_GOTO (this->name, mgmt_lock_timer_xl, ret_function); diff --git a/xlators/mgmt/glusterd/src/glusterd-log-ops.c b/xlators/mgmt/glusterd/src/glusterd-log-ops.c index d04492af7cc..575c104d1c6 100644 --- a/xlators/mgmt/glusterd/src/glusterd-log-ops.c +++ b/xlators/mgmt/glusterd/src/glusterd-log-ops.c @@ -244,6 +244,7 @@ cont: ret = fscanf (file, "%d", &pid); if (ret <= 0) { + fclose (file); gf_msg ("glusterd", GF_LOG_ERROR, errno, GD_MSG_FILE_OP_FAILED, "Unable to read pidfile: %s", pidfile); diff --git a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c index e1583c4a881..cc8fa963b50 100644 --- a/xlators/mgmt/glusterd/src/glusterd-server-quorum.c +++ b/xlators/mgmt/glusterd/src/glusterd-server-quorum.c @@ -364,16 +364,30 @@ glusterd_do_volume_quorum_action (xlator_t *this, glusterd_volinfo_t *volinfo, if (!glusterd_is_local_brick (this, volinfo, brickinfo)) continue; if (quorum_status == DOESNT_MEET_QUORUM) { - glusterd_brick_stop (volinfo, brickinfo, _gf_false); + ret = glusterd_brick_stop (volinfo, brickinfo, + _gf_false); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_STOP_FAIL, "Failed to " + "stop brick %s:%s", + brickinfo->hostname, brickinfo->path); + } } else { if (!brickinfo->start_triggered) { pthread_mutex_lock (&brickinfo->restart_mutex); { - glusterd_brick_start (volinfo, - brickinfo, - _gf_false); + ret = glusterd_brick_start (volinfo, + brickinfo, + _gf_false); } pthread_mutex_unlock (&brickinfo->restart_mutex); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_BRICK_DISCONNECTED, + "Failed to start %s:%s", + brickinfo->hostname, + brickinfo->path); + } } } } diff --git a/xlators/mgmt/glusterd/src/glusterd-sm.c b/xlators/mgmt/glusterd/src/glusterd-sm.c index 18e5e5a3800..a952a4c179e 100644 --- a/xlators/mgmt/glusterd/src/glusterd-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-sm.c @@ -1475,6 +1475,11 @@ glusterd_friend_sm () } ret = glusterd_store_peerinfo (peerinfo); + if (ret) { + gf_msg (this->name, GF_LOG_ERROR, 0, + GD_MSG_PEERINFO_CREATE_FAIL, + "Failed to store peerinfo"); + } rcu_read_unlock (); glusterd_destroy_friend_event_context (event); diff --git a/xlators/mgmt/glusterd/src/glusterd.c b/xlators/mgmt/glusterd/src/glusterd.c index 96019a91050..85ae51ba9fc 100644 --- a/xlators/mgmt/glusterd/src/glusterd.c +++ b/xlators/mgmt/glusterd/src/glusterd.c @@ -1005,7 +1005,7 @@ check_prepare_mountbroker_root (char *mountbroker_root) sys_close (dfd0); if (dfd != -1) sys_close (dfd); - if (dfd2 != -1) + if (dfd2 != -1 && dfd != dfd2) sys_close (dfd2); return ret; @@ -1807,8 +1807,8 @@ init (xlator_t *this) conf->rpc = rpc; conf->uds_rpc = uds_rpc; conf->gfs_mgmt = &gd_brick_prog; - strncpy (conf->workdir, workdir, PATH_MAX); - strncpy (conf->rundir, rundir, PATH_MAX); + (void) strncpy (conf->workdir, workdir, strlen (workdir) + 1); + (void) strncpy (conf->rundir, rundir, strlen (rundir) + 1); synclock_init (&conf->big_lock, SYNC_LOCK_RECURSIVE); pthread_mutex_init (&conf->xprt_lock, NULL); |