mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-15 08:20:59 +02:00
nvmutil: further simplify nr/nw error handling
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+7
-17
@@ -214,16 +214,10 @@ readGbe(void)
|
|||||||
for (int p = 0; p < 2; p++) {
|
for (int p = 0; p < 2; p++) {
|
||||||
if (!do_read[p])
|
if (!do_read[p])
|
||||||
continue;
|
continue;
|
||||||
|
if (pread(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
|
||||||
ssize_t nr = pread(fd, (uint8_t *) gbe[p], nf, p * partsize);
|
err(ERR(), "Couldn't read %ld bytes from '%s' part %d",
|
||||||
if (nr == nf) {
|
nf, filename, p);
|
||||||
swap(p); /* handle big-endian host CPU */
|
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -423,13 +417,9 @@ writeGbe(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
swap(p); /* swap bytes on big-endian host CPUs */
|
swap(p); /* swap bytes on big-endian host CPUs */
|
||||||
ssize_t nw = pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize);
|
if(pwrite(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf)
|
||||||
if (nw == nf)
|
err(ERR(), "Couldn't write %ld bytes to '%s' part '%d'",
|
||||||
continue;
|
nf, filename, p);
|
||||||
|
|
||||||
err(ERR(),
|
|
||||||
"%ld bytes written to '%s' part %d, expected %ld bytes\n",
|
|
||||||
nw, filename, p, nf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err_if(close(fd) == -1);
|
err_if(close(fd) == -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user