summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-10 10:18:25 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-10 10:18:25 +0000
commit890d1a2ff603a1717498ba3d6a74f1c0f27c2415 (patch)
treee57b43ed3731abebb3232d9a84d6179195075c7c /util
parentb56cfbcc54d1e9c8b5e9977d9c70bdc3c8db3038 (diff)
util/nvmutil: err if file offset fails
currently it returns success, if restoring a previous offset failed. this leaves descriptor corrupted when the caller thinks otherwise return -1 instead, so that the caller can treat it as an error, relying on whatever lseek had set for errno Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index f6174352..ac94e690 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1370,13 +1370,13 @@ static ssize_t
prw(int fd, void *mem, size_t count,
off_t offset, int rw_type, const char *path)
{
- off_t rs;
off_t old;
ssize_t r;
if ((old = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
return -1;
- if ((r = lseek_eintr(fd, offset, SEEK_SET)) == (off_t)-1)
+
+ if (lseek_eintr(fd, offset, SEEK_SET) == (off_t)-1)
return -1;
do {
@@ -1389,8 +1389,8 @@ prw(int fd, void *mem, size_t count,
} while (r < 0 && errno == EINTR);
if (r >= 0) {
- if ((rs = lseek_eintr(fd, old, SEEK_SET)) == (off_t)-1)
- errno = EIO;
+ if (lseek_eintr(fd, old, SEEK_SET) == (off_t)-1)
+ return -1;
}
return r;