From 35d8d0993fb93389dc8b10c62789748cf41d3044 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 23 Feb 2026 09:50:26 +0000 Subject: util/nvmutil: simplify nr/nw error handling when nf and nr/nw are not the same, we know there is an error condition, so defer to the following err() call, but use ERR() there instead of hardcoding use of ECANCELED. this actually improves the error handling, by being more verbose, while reducing the amount of logic. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index f2f31692..16a99e54 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -216,13 +216,12 @@ readGbe(void) continue; ssize_t nr = pread(fd, (uint8_t *) gbe[p], nf, p * partsize); - err_if(nr == -1); if (nr == nf) { swap(p); /* handle big-endian host CPU */ continue; } - err(errno == ECANCELED, + err(ERR(), "%ld bytes read from '%s' part %d, expected %ld bytes\n", nr, filename, p, nf); } @@ -425,11 +424,10 @@ writeGbe(void) swap(p); /* swap bytes on big-endian host CPUs */ ssize_t nw = pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize); - err_if(nw == -1); if (nw == nf) continue; - err(errno == ECANCELED, + err(ERR(), "%ld bytes written to '%s' part %d, expected %ld bytes\n", nw, filename, p, nf); } -- cgit v1.2.1