diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-02-23 11:10:12 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-02-23 11:10:12 +0000 |
| commit | 061e6048a864cb1dd6d80052e54b0794af61e6ba (patch) | |
| tree | bc3532df409ada0e9f2ca58adbfd3a21a2e7cdd1 /util/nvmutil | |
| parent | 3d408317b166c4ddfb58b7eaa0914f37ad6f295c (diff) | |
nvmutil: split malloc handling out of readGbe
this has to do with memory allocation, not actual reading
of the gbe file into memory. split it up, for clarity.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 409fc1fb..99900878 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -15,10 +15,10 @@ #include <unistd.h> void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void), - cmd_dump(void), cmd_setmac(void), readGbe(void), checkdir(const char *path), - macf(int partnum), hexdump(int partnum), openFiles(const char *path), - cmd_copy(void), parseMacString(const char *strMac, uint16_t *mac), - cmd_swap(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); int goodChecksum(int partnum); uint8_t hextonum(char chs), rhex(void); @@ -154,6 +154,7 @@ main(int argc, char *argv[]) } err_if((errno = (cmd == NULL) ? EINVAL : errno)); + nvmalloc(); readGbe(); (*cmd)(); writeGbe(); @@ -194,7 +195,7 @@ openFiles(const char *path) } void -readGbe(void) +nvmalloc(void) { if ((cmd == cmd_swap) || (cmd == cmd_copy)) nf = SIZE_4KB; @@ -210,7 +211,11 @@ readGbe(void) gbe[0] = (size_t) buf; gbe[1] = gbe[0] + (nf * (do_read[0] & do_read[1])); +} +void +readGbe(void) +{ for (int p = 0; p < 2; p++) { if (!do_read[p]) continue; |
