From 9b6b89250d8e74850ef04af3cb1dd56b08a69550 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 10 Mar 2026 15:33:50 +0000 Subject: 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 --- util/nvmutil/nvmutil.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'util/nvmutil/nvmutil.c') 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; -- cgit v1.2.1