mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
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>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user