summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVarsha Rao <varao@redhat.com>2018-01-15 14:20:51 +0530
committerAmar Tumballi <amarts@redhat.com>2018-01-18 02:48:59 +0000
commite6feebbb52c0833928d2acd51dd631d7ce5f2ecd (patch)
treee5696fc8b3dde5badd4f9908c0d53caa1e1618f6
parent00751d5abebd538cafdee885cd7b63bb06b20f66 (diff)
performance/io-threads: Fix checked_return coverity error
Change the return type of set_stack_size function to integer and also check the return value of pthread_attr_init(). This fixes the Checked_Return coverity issue. Change-Id: I270b8bd168b09f0b071437c117e4e23b01398534 Signed-off-by: Varsha Rao <varao@redhat.com>
-rw-r--r--xlators/performance/io-threads/src/io-threads.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/xlators/performance/io-threads/src/io-threads.c b/xlators/performance/io-threads/src/io-threads.c
index f89c9d49f2d..bade0d6a807 100644
--- a/xlators/performance/io-threads/src/io-threads.c
+++ b/xlators/performance/io-threads/src/io-threads.c
@@ -849,7 +849,7 @@ out:
}
-void
+int
set_stack_size (iot_conf_t *conf)
{
int err = 0;
@@ -858,22 +858,32 @@ set_stack_size (iot_conf_t *conf)
this = THIS;
- pthread_attr_init (&conf->w_attr);
+ err = pthread_attr_init (&conf->w_attr);
+ if (err != 0) {
+ gf_msg (this->name, GF_LOG_ERROR, err,
+ IO_THREADS_MSG_INIT_FAILED,
+ "Thread attribute initialization failed");
+ return err;
+ }
+
err = pthread_attr_setstacksize (&conf->w_attr, stacksize);
if (err == EINVAL) {
err = pthread_attr_getstacksize (&conf->w_attr, &stacksize);
- if (!err)
+ if (!err) {
gf_msg (this->name, GF_LOG_WARNING,
0, IO_THREADS_MSG_SIZE_NOT_SET,
"Using default thread stack size %zd",
stacksize);
- else
+ } else {
gf_msg (this->name, GF_LOG_WARNING,
0, IO_THREADS_MSG_SIZE_NOT_SET,
"Using default thread stack size");
+ err = 0;
+ }
}
conf->stack_size = stacksize;
+ return err;
}
@@ -1011,7 +1021,10 @@ init (xlator_t *this)
}
conf->mutex_inited = _gf_true;
- set_stack_size (conf);
+ ret = set_stack_size (conf);
+
+ if (ret != 0)
+ goto out;
GF_OPTION_INIT ("thread-count", conf->max_count, int32, out);