From 3d408317b166c4ddfb58b7eaa0914f37ad6f295c Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 23 Feb 2026 11:01:52 +0000 Subject: nvmutil: further simplify nr/nw error handling Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 16a99e54..409fc1fb 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -214,16 +214,10 @@ readGbe(void) for (int p = 0; p < 2; p++) { if (!do_read[p]) continue; - - ssize_t nr = pread(fd, (uint8_t *) gbe[p], nf, p * partsize); - if (nr == nf) { - swap(p); /* handle big-endian host CPU */ - continue; - } - - err(ERR(), - "%ld bytes read from '%s' part %d, expected %ld bytes\n", - nr, filename, p, nf); + if (pread(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf) + err(ERR(), "Couldn't read %ld bytes from '%s' part %d", + nf, filename, p); + swap(p); /* handle big-endian host CPU */ } } @@ -423,13 +417,9 @@ writeGbe(void) continue; swap(p); /* swap bytes on big-endian host CPUs */ - ssize_t nw = pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize); - if (nw == nf) - continue; - - err(ERR(), - "%ld bytes written to '%s' part %d, expected %ld bytes\n", - nw, filename, p, nf); + if(pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf) + err(ERR(), "Couldn't write %ld bytes to '%s' part '%d'", + nf, filename, p); } err_if(close(fd) == -1); -- cgit v1.2.1