From 2ae9ff54467911a1c7e5b65b52a3144aa7a123ed Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 7 Apr 2023 14:11:19 +0100 Subject: util/nvmutil: yet more code size optimisation --- util/nvmutil/nvmutil.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 8292713a..005ee3e7 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -54,7 +54,7 @@ int validChecksum(int partnum); uint16_t word(int pos16, int partnum); void setWord(int pos16, int partnum, uint16_t val16); void byteswap(int n, int partnum); -void writeGbeFile(int *fd, const char *filename); +void writeGbeFile(int *fd, const char *filename, size_t nw); #define FILENAME argv[1] #define COMMAND argv[2] @@ -139,7 +139,7 @@ main(int argc, char *argv[]) else if (cmd != NULL) (*cmd)(); /* all other commands except setmac */ - writeGbeFile(&fd, FILENAME); + writeGbeFile(&fd, FILENAME, nr); if ((errno != 0) && (cmd != &cmd_dump)) err(errno, NULL); @@ -357,15 +357,11 @@ byteswap(int n, int partnum) } void -writeGbeFile(int *fd, const char *filename) +writeGbeFile(int *fd, const char *filename, size_t nw) { - int p, nw = SIZE_4KB; /* copy/swap need all 4KB written */ - if ((gbe[0] != gbe[1]) && (gbe[0] < gbe[1])) /* not copy/swap */ - nw = 128; /* speedhack: write only the nvm part */ if (gbeFileModified) errno = 0; - - for (p = 0; p < 2; p++) { + for (int p = 0; p < 2; p++) { if (gbe[0] > gbe[1]) p ^= 1; /* speedhack: write sequentially on-disk */ if (!nvmPartModified[p]) -- cgit v1.2.1