From d9e9e76188b839447de1d7bdf415a820f13b971b Mon Sep 17 00:00:00 2001 From: karthik-us Date: Thu, 30 Nov 2017 18:39:58 +0530 Subject: features/read-only: Coverity fixes Warning File Function NEGATIVE_RETURNS worm.c worm_writev RESOURCE_LEAK worm.c init read-only.c init Note: COPY_PASTE_ERROR in worm_setattr & worm_fsetattr are false alarms. Change-Id: Iba1b0c18137a8797d7d04502acc87f0b307e1a1c BUG: 789278 Signed-off-by: karthik-us --- xlators/features/read-only/src/read-only.c | 3 ++- xlators/features/read-only/src/worm.c | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'xlators/features') diff --git a/xlators/features/read-only/src/read-only.c b/xlators/features/read-only/src/read-only.c index d72b2c8fd2b..207b2b1a1d6 100644 --- a/xlators/features/read-only/src/read-only.c +++ b/xlators/features/read-only/src/read-only.c @@ -46,9 +46,10 @@ init (xlator_t *this) if (!priv) goto out; + this->private = priv; + GF_OPTION_INIT ("read-only", priv->readonly_or_worm_enabled, bool, out); - this->private = priv; ret = 0; out: return ret; diff --git a/xlators/features/read-only/src/worm.c b/xlators/features/read-only/src/worm.c index d37a930c1fc..088dd5a1b23 100644 --- a/xlators/features/read-only/src/worm.c +++ b/xlators/features/read-only/src/worm.c @@ -434,9 +434,12 @@ worm_writev (call_frame_t *frame, xlator_t *this, fd_t *fd, op_errno = gf_worm_state_transition (this, _gf_true, fd, GF_FOP_WRITE); out: - if (op_errno) + if (op_errno) { + if (op_errno < 0) + op_errno = EROFS; STACK_UNWIND_STRICT (writev, frame, -1, op_errno, NULL, NULL, NULL); + } else STACK_WIND_TAIL (frame, FIRST_CHILD (this), FIRST_CHILD (this)->fops->writev, @@ -535,6 +538,8 @@ init (xlator_t *this) goto out; } + this->private = priv; + GF_OPTION_INIT ("worm", priv->readonly_or_worm_enabled, bool, out); GF_OPTION_INIT ("worm-file-level", priv->worm_file, bool, out); @@ -545,7 +550,6 @@ init (xlator_t *this) GF_OPTION_INIT ("worm-files-deletable", priv->worm_files_deletable, bool, out); - this->private = priv; ret = 0; out: return ret; -- cgit