summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-10 15:33:50 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-10 15:33:50 +0000
commit9b6b89250d8e74850ef04af3cb1dd56b08a69550 (patch)
treed33adf72151cd5ecc7a96f0f81ab0ebe531aa284 /util/nvmutil/nvmutil.c
parentb28076557b4c12965c15d6fad7c06e34c67f7921 (diff)
util/nvmutil: don't use bad pointer cast in prw
in practise it's ok, but some compilers might complain. all this change costs is a bit of branching inside a loop, but compilers will sort that out. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 49902814..b339e608 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -1468,16 +1468,6 @@ prw(int fd, void *mem, size_t nrw,
off_t off_orig;
ssize_t r;
int saved_errno;
- ssize_t (*op)(int, void *, size_t);
-
- if (rw_type == PLESEN)
- op = read;
- else if (rw_type == PSCHREIB)
- op = (ssize_t (*)(int, void *, size_t))write;
- else {
- errno = EINVAL;
- return -1;
- }
if ((off_orig = lseek_eintr(fd, (off_t)0, SEEK_CUR)) == (off_t)-1)
return -1;
@@ -1485,7 +1475,14 @@ prw(int fd, void *mem, size_t nrw,
return -1;
do {
- r = op(fd, mem, nrw);
+ if (rw_type == PLESEN)
+ r = read(fd, mem, nrw);
+ else if (rw_type == PSCHREIB)
+ r = write(fd, mem, nrw);
+ else {
+ errno = EINVAL;
+ return -1;
+ }
} while (r < 0 && errno == EINTR);
saved_errno = errno;