diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-02-23 09:50:26 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-02-23 09:50:26 +0000 |
| commit | 35d8d0993fb93389dc8b10c62789748cf41d3044 (patch) | |
| tree | 5989ad1d8eed5dbafae7804381cf63d5dab79f81 /util/nvmutil/nvmutil.c | |
| parent | 4473179300991ff87ad124fb43261e14992c1035 (diff) | |
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 <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 6 |
1 files changed, 2 insertions, 4 deletions
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); } |
