diff options
author | Ashish Pandey <aspandey@redhat.com> | 2017-11-07 13:05:56 +0530 |
---|---|---|
committer | Jeff Darcy <jeff@pl.atyp.us> | 2017-11-13 16:31:27 +0000 |
commit | 4ded7d84ccd4a5391788a66029bf5c2424f6e08a (patch) | |
tree | eeeacf1030794bbb2ea04466cb17da50cb41aa80 /xlators | |
parent | 7d00abbf57f93cc2e6064d9bc94facbb961335c7 (diff) |
debug/io-stats: Coverity fix in io-stats
Coverity ID: 539
Coverity ID: 542
Coverity ID: 365
Coverity ID: 366
Coverity ID: 502
Coverity ID: 76
Change-Id: I0369856e8958e167a43065801096432b8855c114
BUG: 789278
Signed-off-by: Ashish Pandey <aspandey@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/debug/io-stats/src/io-stats.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/xlators/debug/io-stats/src/io-stats.c b/xlators/debug/io-stats/src/io-stats.c index b660e5ac8cb..892746c959a 100644 --- a/xlators/debug/io-stats/src/io-stats.c +++ b/xlators/debug/io-stats/src/io-stats.c @@ -746,7 +746,7 @@ _io_stats_get_key_prefix (xlator_t *this, char **key_prefix) { strlen (instance_name) + 3; *key_prefix = GF_CALLOC (key_len, sizeof (char), gf_common_mt_char); - if (!key_prefix) { + if (!*key_prefix) { ret = -ENOMEM; goto err; } @@ -761,7 +761,7 @@ _io_stats_get_key_prefix (xlator_t *this, char **key_prefix) { key_len = strlen (key_root) + strlen (xlator_name) + 2; *key_prefix = GF_CALLOC (key_len, sizeof (char), gf_common_mt_char); - if (!key_prefix) { + if (!*key_prefix) { ret = -ENOMEM; goto err; } @@ -1090,6 +1090,9 @@ _io_stats_write_latency_sample (xlator_t *this, ios_sample_t *sample, username = _resolve_username (this, sample->uid); if (!username) { username = GF_MALLOC (30, gf_common_mt_char); + if (!username) { + goto out; + } sprintf (username, "%d", (int32_t)sample->uid); } @@ -1097,6 +1100,9 @@ _io_stats_write_latency_sample (xlator_t *this, ios_sample_t *sample, group_name = _resolve_group_name (this, sample->gid); if (!group_name) { group_name = GF_MALLOC (30, gf_common_mt_char); + if (!group_name) { + goto out; + } sprintf (group_name, "%d", (int32_t)sample->gid); } @@ -3824,8 +3830,14 @@ reconfigure (xlator_t *this, dict_t *options) GF_OPTION_RECONF ("ios-dump-interval", conf->ios_dump_interval, options, int32, out); if ((old_dump_interval <= 0) && (conf->ios_dump_interval > 0)) { - gf_thread_create (&conf->dump_thread, NULL, + ret = gf_thread_create (&conf->dump_thread, NULL, (void *) &_ios_dump_thread, this, "iosdump"); + if (ret) { + gf_log (this ? this->name : "io-stats", + GF_LOG_ERROR, "Failed to start thread" + "while reconfigure. Returning %d", ret); + goto out; + } } GF_OPTION_RECONF ("ios-sample-interval", conf->ios_sample_interval, @@ -4005,10 +4017,11 @@ init (xlator_t *this) GF_OPTION_INIT ("ios-sample-buf-size", conf->ios_sample_buf_size, int32, out); - if (ios_init_sample_buf (conf) != 0) { + ret = ios_init_sample_buf (conf); + if (ret) { gf_log (this->name, GF_LOG_ERROR, "Out of memory."); - return -1; + goto out; } GF_OPTION_INIT ("ios-dnscache-ttl-sec", conf->ios_dnscache_ttl_sec, @@ -4048,16 +4061,19 @@ init (xlator_t *this) this->private = conf; if (conf->ios_dump_interval > 0) { - gf_thread_create (&conf->dump_thread, NULL, - (void *) &_ios_dump_thread, this, "iosdump"); + ret = gf_thread_create (&conf->dump_thread, NULL, + (void *) &_ios_dump_thread, + this, "iosdump"); + if (ret) { + gf_log (this ? this->name : "io-stats", + GF_LOG_ERROR, "Failed to start thread" + "in init. Returning %d", ret); + goto out; + } } - ret = 0; + return 0; out: - if (!this->private) { - ios_conf_destroy (conf); - ret = -1; - } - + ios_conf_destroy (conf); return ret; } |