summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
authorAmar Tumballi <amarts@redhat.com>2018-08-18 11:39:03 +0530
committerNiels de Vos <ndevos@redhat.com>2018-08-19 10:03:52 +0000
commitfab6944206bf44e2260f20a9d5f1e785f933e705 (patch)
tree0eef23967b99436f0aab400b29a4c703a337d3d1 /libglusterfs/src
parent23e2a420f90c4d39386a0c0c2a8bea0e376ab070 (diff)
coverity: libglusterfs issues
CID: 1391415, 1274122, 1274201, 1382408, 1382437, 1389436 1288798, 1288106, 1288110 updates: bz#789278 Change-Id: I48c7a50f22f5f4580310040c66463d9f7dd26204 Signed-off-by: Amar Tumballi <amarts@redhat.com>
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/client_t.c3
-rw-r--r--libglusterfs/src/event-epoll.c15
-rw-r--r--libglusterfs/src/event.c8
-rw-r--r--libglusterfs/src/graph.c2
-rw-r--r--libglusterfs/src/logging.c4
-rw-r--r--libglusterfs/src/mem-pool.c3
-rw-r--r--libglusterfs/src/stack.c2
-rw-r--r--libglusterfs/src/syncop.c2
-rw-r--r--libglusterfs/src/syscall.c4
9 files changed, 33 insertions, 10 deletions
diff --git a/libglusterfs/src/client_t.c b/libglusterfs/src/client_t.c
index aeade5b3a20..046f72e021d 100644
--- a/libglusterfs/src/client_t.c
+++ b/libglusterfs/src/client_t.c
@@ -744,7 +744,8 @@ gf_client_dump_fdtables_to_dict (xlator_t *this, dict_t *dict)
clienttable->cliententries[count].next_free)
continue;
client = clienttable->cliententries[count].client;
- if (!strcmp (client->bound_xl->name, this->name)) {
+ if (client->bound_xl &&
+ !strcmp (client->bound_xl->name, this->name)) {
snprintf (key, sizeof (key), "conn%d", count++);
fdtable_dump_to_dict (client->server_ctx.
fdtable,
diff --git a/libglusterfs/src/event-epoll.c b/libglusterfs/src/event-epoll.c
index ed58899caa8..8ff66a8445f 100644
--- a/libglusterfs/src/event-epoll.c
+++ b/libglusterfs/src/event-epoll.c
@@ -212,18 +212,18 @@ event_slot_unref (struct event_pool *event_pool, struct event_slot_epoll *slot,
int do_close = 0;
ref = GF_ATOMIC_DEC (slot->ref);
+ if (ref)
+ /* slot still alive */
+ goto done;
LOCK (&slot->lock);
{
fd = slot->fd;
do_close = slot->do_close;
+ slot->do_close = 0;
}
UNLOCK (&slot->lock);
- if (ref)
- /* slot still alive */
- goto done;
-
event_slot_dealloc (event_pool, idx);
if (do_close)
@@ -580,6 +580,8 @@ event_dispatch_epoll_handler (struct event_pool *event_pool,
pre_unlock:
UNLOCK (&slot->lock);
+ ret = 0;
+
if (!handler)
goto out;
@@ -661,6 +663,11 @@ event_dispatch_epoll_worker (void *data)
continue;
ret = event_dispatch_epoll_handler (event_pool, &event);
+ if (ret) {
+ gf_msg ("epoll", GF_LOG_ERROR, 0,
+ LG_MSG_EXITED_EPOLL_THREAD,
+ "Failed to dispatch handler");
+ }
}
out:
if (ev_data)
diff --git a/libglusterfs/src/event.c b/libglusterfs/src/event.c
index 61006c100fa..2598cd305a8 100644
--- a/libglusterfs/src/event.c
+++ b/libglusterfs/src/event.c
@@ -277,6 +277,14 @@ event_dispatch_destroy (struct event_pool *event_pool)
ret = pthread_cond_timedwait (&event_pool->cond,
&event_pool->mutex,
&sleep_till);
+ if (ret) {
+ gf_msg_debug ("event", 0,
+ "thread cond-timedwait failed "
+ "active-thread-count: %d, "
+ "retry: %d",
+ event_pool->activethreadcount,
+ retry);
+ }
}
}
pthread_mutex_unlock (&event_pool->mutex);
diff --git a/libglusterfs/src/graph.c b/libglusterfs/src/graph.c
index e54f62bf518..2a171f3b8dc 100644
--- a/libglusterfs/src/graph.c
+++ b/libglusterfs/src/graph.c
@@ -93,7 +93,7 @@ glusterfs_read_secure_access_file (void)
start = result[0].rm_so;
end = result[0].rm_eo;
copy_len = end - start;
- strcpy (keyval, line+copy_len);
+ gf_strncpy (keyval, line+copy_len, sizeof (keyval));
if (keyval[0]) {
cert_depth = atoi(keyval);
if (cert_depth == 0)
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index 732c4b26473..a46cb234b72 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -2504,7 +2504,7 @@ out:
return ret;
}
-int
+static int
_do_slog_format (const char *event, va_list inp, char **msg) {
va_list valist_tmp;
int i = 0;
@@ -2585,7 +2585,7 @@ _do_slog_format (const char *event, va_list inp, char **msg) {
}
*msg = gf_strdup (tmp2);
- if (!msg)
+ if (!*msg)
ret = -1;
out:
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index 252bae5d7e3..4b140296b4f 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -825,9 +825,9 @@ mem_get (struct mem_pool *mem_pool)
(void) pthread_spin_lock (&pool_list->lock);
pt_pool = &pool_list->pools[mem_pool->pool->power_of_two-POOL_SMALLEST];
retval = mem_get_from_pool (pt_pool);
- (void) pthread_spin_unlock (&pool_list->lock);
if (!retval) {
+ (void) pthread_spin_unlock (&pool_list->lock);
return NULL;
}
@@ -835,6 +835,7 @@ mem_get (struct mem_pool *mem_pool)
retval->pool = mem_pool;
retval->pool_list = pool_list;
retval->power_of_two = mem_pool->pool->power_of_two;
+ (void) pthread_spin_unlock (&pool_list->lock);
GF_ATOMIC_INC (mem_pool->active);
diff --git a/libglusterfs/src/stack.c b/libglusterfs/src/stack.c
index c4cfebc484a..13107e4e3bc 100644
--- a/libglusterfs/src/stack.c
+++ b/libglusterfs/src/stack.c
@@ -212,7 +212,7 @@ gf_proc_dump_pending_frames (call_pool_t *call_pool)
call_stack_t *trav = NULL;
int i = 1;
int ret = -1;
- gf_boolean_t section_added = _gf_true;
+ gf_boolean_t section_added = _gf_false;
if (!call_pool)
return;
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index 767d2ef6853..8323dd71a10 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -467,6 +467,8 @@ synctask_create (struct syncenv *env, size_t stacksize, synctask_fn_t fn,
newtask->frame = frame;
if (!frame) {
newtask->opframe = create_frame (this, this->ctx->pool);
+ if (!newtask->opframe)
+ goto err;
set_lk_owner_from_ptr (&newtask->opframe->root->lk_owner,
newtask->opframe->root);
} else {
diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c
index 2d79d695b09..6a17d1ec6ca 100644
--- a/libglusterfs/src/syscall.c
+++ b/libglusterfs/src/syscall.c
@@ -493,6 +493,8 @@ gf_add_prefix(const char *ns, const char *key, char **newkey)
int ns_length = strlen(ns);
*newkey = GF_MALLOC(ns_length + strlen(key) + 10,
gf_common_mt_char);
+ if (!*newkey)
+ return;
strcpy(*newkey, ns);
strcat(*newkey, key);
} else {
@@ -507,6 +509,8 @@ gf_remove_prefix(const char *ns, const char *key, char **newkey)
if (strncmp(key, ns, ns_length) == 0) {
*newkey = GF_MALLOC(-ns_length + strlen(key) + 10,
gf_common_mt_char);
+ if (!*newkey)
+ return;
strcpy(*newkey, key + ns_length);
} else {
*newkey = gf_strdup(key);