From: Utkal Singh <singhutkal015@gmail.com>
To: linux-erofs@lists.ozlabs.org
Cc: hsiangkao@linux.alibaba.com, zhaoyifan28@huawei.com,
Utkal Singh <singhutkal015@gmail.com>
Subject: [PATCH] erofs-utils: lib: fix error code loss in erofs_io_fallocate()
Date: Sat, 14 Mar 2026 21:06:14 +0000 [thread overview]
Message-ID: <20260314210614.8994-1-singhutkal015@gmail.com> (raw)
The final erofs_io_pwrite() call in erofs_io_fallocate() used a
ternary expression that discarded the real return value. If
erofs_io_pwrite() returned a negative error code such as -ENOSPC,
the caller would receive -EIO instead, losing the original error
information and making failures harder to diagnose.
Fix this by storing the return value in ret and propagating the
real error code directly, consistent with the loop above it.
Signed-off-by: Utkal Singh <singhutkal015@gmail.com>
---
lib/io.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/io.c b/lib/io.c
index 0c5eb2c..12a9beb 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -191,7 +191,10 @@ int erofs_io_fallocate(struct erofs_vfile *vf, u64 offset,
len -= ret;
offset += ret;
}
- return erofs_io_pwrite(vf, erofs_zeroed, offset, len) == len ? 0 : -EIO;
+ ret = erofs_io_pwrite(vf, erofs_zeroed, offset, len);
+ if (ret != (ssize_t)len)
+ return ret < 0 ? (int)ret : -EIO;
+ return 0;
}
int erofs_io_ftruncate(struct erofs_vfile *vf, u64 length)
--
2.43.0
reply other threads:[~2026-03-14 21:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260314210614.8994-1-singhutkal015@gmail.com \
--to=singhutkal015@gmail.com \
--cc=hsiangkao@linux.alibaba.com \
--cc=linux-erofs@lists.ozlabs.org \
--cc=zhaoyifan28@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox