summaryrefslogtreecommitdiffstats
path: root/xlators/cluster
diff options
context:
space:
mode:
authorN Balachandran <nbalacha@redhat.com>2018-08-09 11:14:11 +0530
committerN Balachandran <nbalacha@redhat.com>2018-08-21 15:25:49 +0000
commitfcd0c24abfccfe8d1faf64269a113596577355a8 (patch)
treed7dee1499793190d077a9d905c87f4fcc10dc294 /xlators/cluster
parent2ea2d68776e21f4bfa8d13fc79b7a7ef0818ad0b (diff)
cluster/dht: coverity fixes
Fixes 1133997, 1370910, 1382387, 1382444, 1394635 Change-Id: Ie63ad47abd5519b9b9536da26b61ed4c9eaf2c75 updates: bz#789278 Signed-off-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r--xlators/cluster/dht/src/dht-common.c25
-rw-r--r--xlators/cluster/dht/src/dht-rebalance.c1
2 files changed, 14 insertions, 12 deletions
diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 055c92fcbfc..9ae80b33fe3 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -1277,9 +1277,7 @@ dht_dir_xattr_heal (xlator_t *this, dht_local_t *local)
int ret = -1;
char gfid_local[GF_UUID_BUF_SIZE] = {0};
- if (local->gfid) {
- gf_uuid_unparse(local->gfid, gfid_local);
- } else {
+ if (gf_uuid_is_null (local->gfid)) {
gf_msg (this->name, GF_LOG_ERROR, 0,
DHT_MSG_DIR_XATTR_HEAL_FAILED,
"No gfid exists for path %s "
@@ -1288,6 +1286,7 @@ dht_dir_xattr_heal (xlator_t *this, dht_local_t *local)
goto out;
}
+ gf_uuid_unparse(local->gfid, gfid_local);
copy = create_frame (this, this->ctx->pool);
if (copy) {
copy_local = dht_local_init (copy, &(local->loc), NULL, 0);
@@ -1358,8 +1357,9 @@ dht_lookup_dir_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
if (!op_ret && gf_uuid_is_null (local->gfid)) {
memcpy (local->gfid, stbuf->ia_gfid, 16);
}
- if (local->gfid)
+ if (!gf_uuid_is_null(local->gfid)) {
gf_uuid_unparse(local->gfid, gfid_local);
+ }
/* Check if the gfid is different for file from other node */
if (!op_ret && gf_uuid_compare (local->gfid, stbuf->ia_gfid)) {
@@ -5198,7 +5198,8 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
op_errno = ENOMEM;
goto err;
}
- (void) strncpy (local->xsel, node_uuid_key, 256);
+ (void) snprintf (local->xsel, sizeof (local->xsel), "%s",
+ node_uuid_key);
cnt = local->call_cnt = conf->subvolume_cnt;
for (i = 0; i < cnt; i++) {
STACK_WIND_COOKIE (frame, dht_find_local_subvol_cbk,
@@ -5223,7 +5224,8 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
op_errno = ENOMEM;
goto err;
}
- (void) strncpy (local->xsel, node_uuid_key, 256);
+ (void) snprintf (local->xsel, sizeof (local->xsel), "%s",
+ node_uuid_key);
cnt = local->call_cnt = conf->subvolume_cnt;
for (i = 0; i < cnt; i++) {
STACK_WIND_COOKIE (frame, dht_find_local_subvol_cbk,
@@ -5251,7 +5253,7 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
(XATTR_IS_PATHINFO (key)
|| (strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0)
|| (strcmp (key, GF_XATTR_LIST_NODE_UUIDS_KEY) == 0))) {
- (void) strncpy (local->xsel, key, 256);
+ (void) snprintf (local->xsel, sizeof (local->xsel), "%s", key);
cnt = local->call_cnt = layout->cnt;
for (i = 0; i < cnt; i++) {
subvol = layout->list[i].xlator;
@@ -5266,8 +5268,7 @@ dht_getxattr (call_frame_t *frame, xlator_t *this,
if (key && ((strcmp (key, GF_XATTR_NODE_UUID_KEY) == 0)
|| XATTR_IS_PATHINFO (key))) {
cached_subvol = local->cached_subvol;
- (void) strncpy (local->xsel, key, 256);
-
+ (void) snprintf (local->xsel, sizeof (local->xsel), "%s", key);
local->call_cnt = 1;
STACK_WIND_COOKIE (frame, dht_vgetxattr_cbk, cached_subvol,
cached_subvol, cached_subvol->fops->getxattr,
@@ -5617,8 +5618,9 @@ dht_dir_common_set_remove_xattr (call_frame_t *frame, xlator_t *this, loc_t *loc
call_cnt = conf->subvolume_cnt;
local->flags = flags;
- if (local->gfid)
+ if (!gf_uuid_is_null (local->gfid)) {
gf_uuid_unparse(local->gfid, gfid_local);
+ }
if ((local->fop == GF_FOP_SETXATTR) ||
(local->fop == GF_FOP_FSETXATTR)) {
@@ -9655,7 +9657,7 @@ dht_mkdir (call_frame_t *frame, xlator_t *this,
{
dht_local_t *local = NULL;
dht_conf_t *conf = NULL;
- int op_errno = -1, ret = -1;
+ int op_errno = EINVAL, ret = -1;
xlator_t *hashed_subvol = NULL;
char pgfid[GF_UUID_BUF_SIZE] = {0};
call_stub_t *stub = NULL;
@@ -11060,7 +11062,6 @@ dht_ipc (call_frame_t *frame, xlator_t *this, int32_t op, dict_t *xdata)
return 0;
err:
- op_errno = (op_errno == -1) ? errno : op_errno;
DHT_STACK_UNWIND (ipc, frame, -1, op_errno, NULL);
return 0;
diff --git a/xlators/cluster/dht/src/dht-rebalance.c b/xlators/cluster/dht/src/dht-rebalance.c
index e25064ea26e..d3cfc869f8d 100644
--- a/xlators/cluster/dht/src/dht-rebalance.c
+++ b/xlators/cluster/dht/src/dht-rebalance.c
@@ -4590,6 +4590,7 @@ gf_defrag_estimates_init (xlator_t *this, loc_t *loc,
gf_msg (this->name, GF_LOG_ERROR, ret, 0, "Failed to "
"create the file counter thread ");
ret = -1;
+ goto out;
}
ret = 0;
out: