From 678b9d859b788bb0c4aa6353d650ae616add86d7 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 23 Feb 2026 13:45:28 +0000 Subject: nvmutil: split pread from readGbe split it into readGbe_part, for code clarity. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'util') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index ee86de14..25a372c7 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -18,7 +18,8 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void), cmd_dump(void), cmd_setmac(void), nvmalloc(void), readGbe(void), checkdir(const char *path), macf(int partnum), hexdump(int partnum), parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void), - openFiles(const char *path), cmd_copy(void), writeGbe_part(int); + openFiles(const char *path), cmd_copy(void), writeGbe_part(int), + readGbe_part(int); int goodChecksum(int partnum); uint8_t hextonum(char chs), rhex(void); @@ -221,15 +222,19 @@ void readGbe(void) { for (int p = 0; p < 2; p++) { - if (!do_read[p]) - continue; - 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 */ + if (do_read[p]) + readGbe_part(p); } } +void +readGbe_part(int p) +{ + if (pread(fd, (uint8_t *) gbe[p], nf, p * partsize) != nf) + err(ERR(), "Can't read %ld b from '%s' p%d", nf, filename, p); + swap(p); /* handle big-endian host CPU */ +} + void cmd_setmac(void) { -- cgit v1.2.1