From 1ef8a597db1ead482612f2f0bcc212d9a1349ccb Mon Sep 17 00:00:00 2001 From: "M. Mohan Kumar" Date: Fri, 15 Nov 2013 17:50:34 +0530 Subject: Fixes for ZF reported by coverity BUG: 1028673 Change-Id: I7c75738cca22c81c5629d579ef5bea24000e622e Signed-off-by: M. Mohan Kumar Reviewed-on: http://review.gluster.org/6291 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/stripe/src/stripe.c | 4 +++- xlators/protocol/client/src/client-rpc-fops.c | 4 +++- xlators/storage/posix/src/posix.c | 6 +++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index fa718a3e4e5..8ac14cb3a87 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -4117,7 +4117,9 @@ stripe_zerofill_cbk(call_frame_t *frame, void *cookie, xlator_t *this, call_frame_t *prev = NULL; call_frame_t *mframe = NULL; - if (!this || !frame || !frame->local || !cookie) { + GF_ASSERT (frame); + + if (!this || !frame->local || !cookie) { gf_log ("stripe", GF_LOG_DEBUG, "possible NULL deref"); goto out; } diff --git a/xlators/protocol/client/src/client-rpc-fops.c b/xlators/protocol/client/src/client-rpc-fops.c index 6355450c393..6901d8e2c3b 100644 --- a/xlators/protocol/client/src/client-rpc-fops.c +++ b/xlators/protocol/client/src/client-rpc-fops.c @@ -6053,7 +6053,9 @@ client3_3_zerofill(call_frame_t *frame, xlator_t *this, void *data) int op_errno = ESTALE; int ret = 0; - if (!frame || !this || !data) + GF_ASSERT (frame); + + if (!this || !data) goto unwind; args = data; diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index 768ab492937..de785420555 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -686,7 +686,11 @@ _posix_do_zerofill(int fd, off_t offset, off_t len, int o_direct) vector[idx].iov_base = iov_base; vector[idx].iov_len = vect_size; } - lseek(fd, offset, SEEK_SET); + if (lseek(fd, offset, SEEK_SET) < 0) { + op_ret = -1; + goto err; + } + for (idx = 0; idx < num_loop; idx++) { op_ret = writev(fd, vector, num_vect); if (op_ret < 0) -- cgit