diff options
author | Atin Mukherjee <amukherj@redhat.com> | 2018-11-03 12:13:29 +0530 |
---|---|---|
committer | Atin Mukherjee <amukherj@redhat.com> | 2018-11-03 19:06:59 +0530 |
commit | aad1e56286c35237decb106434596fb7f081ee53 (patch) | |
tree | e3bbd92107420e36cfcea60e364c86dadb4e383f | |
parent | 91cb12be96fb543ee9c0b47bfa8792786286aff7 (diff) |
glusterd: coverity fixes
Addresses CIDs : 1124769, 1124852, 1124864, 1134024, 1229876, 1382382
Also addressed a spurious failure in
tests/bugs/glusterd/df-results-post-replace-brick-operations.t to ensure
post replace brick operation and before triggering 'df' from mount,
client has connection to the newly replaced bricks.
Change-Id: Ie5d7e02f89400a661491d7fc2a120d6f6a83a1cc
Updates: bz#789278
Signed-off-by: Atin Mukherjee <amukherj@redhat.com>
-rw-r--r-- | tests/bugs/glusterd/df-results-post-replace-brick-operations.t | 3 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-utils.c | 14 |
2 files changed, 11 insertions, 6 deletions
diff --git a/tests/bugs/glusterd/df-results-post-replace-brick-operations.t b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t index 443911ceed4..04f75889388 100644 --- a/tests/bugs/glusterd/df-results-post-replace-brick-operations.t +++ b/tests/bugs/glusterd/df-results-post-replace-brick-operations.t @@ -53,6 +53,9 @@ total_space=$(df -P $M0 | tail -1 | awk '{ print $2}') TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1/brick1 $H0:$B0/${V0}4/brick1 commit force TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}2/brick1 $H0:$B0/${V0}5/brick1 commit force +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 0 +EXPECT_WITHIN $CHILD_UP_TIMEOUT "1" afr_child_up_status $V0 1 + # check for the size at mount point, it should be same as previous total_space_new=$(df -P $M0 | tail -1 | awk '{ print $2}') TEST [ $total_space -eq $total_space_new ] diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c index 7b8369f623b..7687a8b9d67 100644 --- a/xlators/mgmt/glusterd/src/glusterd-utils.c +++ b/xlators/mgmt/glusterd/src/glusterd-utils.c @@ -2833,7 +2833,7 @@ glusterd_volume_compute_cksum(glusterd_volinfo_t *volinfo, char *cksum_path, *cs = cksum; out: - if (fd > 0) + if (fd != -1) sys_close(fd); if (unlink_sortfile) sys_unlink(sort_filepath); @@ -3761,7 +3761,8 @@ glusterd_import_new_brick(dict_t *peer_data, int32_t vol_count, } new_brickinfo->decommissioned = decommissioned; if (brick_id) - strcpy(new_brickinfo->brick_id, brick_id); + gf_strncpy(new_brickinfo->brick_id, brick_id, + sizeof(new_brickinfo->brick_id)); snprintf(key, sizeof(key), "%s%d.brick%d", prefix, vol_count, brick_count); ret = gd_import_new_brick_snap_details(peer_data, key, new_brickinfo); @@ -8436,9 +8437,9 @@ glusterd_brick_signal(glusterd_volinfo_t *volinfo, kill(pid, sig); sleep(1); + sys_unlink(dumpoptions_path); ret = 0; out: - sys_unlink(dumpoptions_path); if (pidfile) fclose(pidfile); return ret; @@ -8533,11 +8534,11 @@ glusterd_nfs_statedump(char *options, int option_cnt, char **op_errstr) sleep(1); + sys_unlink(dumpoptions_path); ret = 0; out: if (pidfile) fclose(pidfile); - sys_unlink(dumpoptions_path); GF_FREE(dup_options); return ret; } @@ -8658,11 +8659,11 @@ glusterd_quotad_statedump(char *options, int option_cnt, char **op_errstr) sleep(1); + sys_unlink(dumpoptions_path); ret = 0; out: if (pidfile) fclose(pidfile); - sys_unlink(dumpoptions_path); GF_FREE(dup_options); return ret; } @@ -12881,7 +12882,8 @@ glusterd_update_mntopts(char *brick_path, glusterd_brickinfo_t *brickinfo) ret = -1; goto out; } - strcpy(brickinfo->mnt_opts, entry->mnt_opts); + gf_strncpy(brickinfo->mnt_opts, entry->mnt_opts, + sizeof(brickinfo->mnt_opts)); ret = 0; out: |