summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManikandan Selvaganesh <mselvaga@redhat.com>2015-02-10 14:59:09 +0530
committerVijay Bellur <vbellur@redhat.com>2015-04-07 03:52:05 -0700
commitaa0befea352402922839dd846c798c0da2afd271 (patch)
tree4d813cd07658bafa012f667d02578f329ee93eb5
parenta0e3634c6f0d349a3433cdbeabd93043f5f43e9d (diff)
dht : coverity fixes
CID : 1124352,1124365 (unchecked return value), 1124377 ( logically dead code), 1124511 (null dereference) Change-Id: I61e029a078559cfe15d36bf0aa53418f6214e5cb BUG: 789278 Signed-off-by: Manikandan Selvaganesh <mselvaga@redhat.com> Reviewed-on: http://review.gluster.org/9622 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com> Reviewed-by: N Balachandran <nbalacha@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
-rw-r--r--xlators/cluster/dht/src/dht-layout.c10
-rw-r--r--xlators/cluster/dht/src/dht-rename.c4
-rw-r--r--xlators/cluster/dht/src/dht-shared.c8
3 files changed, 12 insertions, 10 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index bbac904743e..2ed15c5e43c 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -69,6 +69,7 @@ dht_layout_get (xlator_t *this, inode_t *inode)
{
dht_conf_t *conf = NULL;
dht_layout_t *layout = NULL;
+ int ret = 0;
conf = this->private;
if (!conf)
@@ -76,8 +77,8 @@ dht_layout_get (xlator_t *this, inode_t *inode)
LOCK (&conf->layout_lock);
{
- dht_inode_ctx_layout_get (inode, this, &layout);
- if (layout) {
+ ret = dht_inode_ctx_layout_get (inode, this, &layout);
+ if ((!ret) && layout) {
layout->ref++;
}
}
@@ -97,13 +98,14 @@ dht_layout_set (xlator_t *this, inode_t *inode, dht_layout_t *layout)
dht_layout_t *old_layout;
conf = this->private;
- if (!conf)
+ if (!conf || !layout)
goto out;
LOCK (&conf->layout_lock);
{
oldret = dht_inode_ctx_layout_get (inode, this, &old_layout);
- layout->ref++;
+ if (layout)
+ layout->ref++;
dht_inode_ctx_layout_set (inode, this, layout);
}
UNLOCK (&conf->layout_lock);
diff --git a/xlators/cluster/dht/src/dht-rename.c b/xlators/cluster/dht/src/dht-rename.c
index 7d73eb9f272..0594945203e 100644
--- a/xlators/cluster/dht/src/dht-rename.c
+++ b/xlators/cluster/dht/src/dht-rename.c
@@ -792,16 +792,12 @@ unwind:
WIPE (&local->postoldparent);
WIPE (&local->preparent);
WIPE (&local->postparent);
- if (xattr)
- dict_unref (xattr);
dht_rename_done (frame, this);
return 0;
cleanup:
- if (xattr)
- dict_unref (xattr);
dht_rename_cleanup (frame);
return 0;
diff --git a/xlators/cluster/dht/src/dht-shared.c b/xlators/cluster/dht/src/dht-shared.c
index 0c008d83653..fc281b80287 100644
--- a/xlators/cluster/dht/src/dht-shared.c
+++ b/xlators/cluster/dht/src/dht-shared.c
@@ -594,8 +594,12 @@ dht_init (xlator_t *this)
conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_ON;
if (dict_get_str (this->options, "lookup-unhashed", &temp_str) == 0) {
/* If option is not "auto", other options _should_ be boolean */
- if (strcasecmp (temp_str, "auto"))
- gf_string2boolean (temp_str, &conf->search_unhashed);
+ if (strcasecmp (temp_str, "auto")) {
+ ret = gf_string2boolean (temp_str,
+ &conf->search_unhashed);
+ if (ret == -1)
+ goto err;
+ }
else
conf->search_unhashed = GF_DHT_LOOKUP_UNHASHED_AUTO;
}