util/nvmutil: yet more code size optimisation

fsdg20230625
Leah Rowe 2023-04-07 14:11:19 +01:00
parent bae37e30ea
commit 2ae9ff5446
1 changed files with 4 additions and 8 deletions

View File

@ -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])