summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-02 23:26:02 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-02 23:26:02 +0000
commit53e386d2b59f85c345eda2facd3084f996c7cf26 (patch)
tree220dd9c359c6dca9ea7718db595df327ada34089 /util/nvmutil/nvmutil.c
parent3248b8f651a645da770af52674d2a841083ad830 (diff)
util/nvmutil: don't use size_t as pointer
the only reason i did this was for that xor swap, but we can just use an intermediary value Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 8692d096..bbbb4e3f 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -40,7 +40,8 @@ uint16_t word(int, int);
uint16_t mac[3] = {0, 0, 0};
ssize_t nf;
-size_t partsize, gbe[2];
+size_t partsize;
+uint8_t *gbe[2];
uint8_t nvmPartChanged[2] = {0, 0}, do_read[2] = {1, 1};
int flags, rfd, fd, part, e = 1;
@@ -197,11 +198,11 @@ nvmalloc(void)
do_read[part ^ 1] = 0;
/* only allocate one block if only one part being read */
- char *buf = malloc(nf << (do_read[0] & do_read[1]));
+ uint8_t *buf = (uint8_t *) malloc(nf << (do_read[0] & do_read[1]));
if (buf == NULL)
err(errno, NULL);
- gbe[0] = (size_t) buf;
+ gbe[0] = buf;
/* speedhack: for cmd copy, both pointers are set the same */
gbe[1] = gbe[0] + (nf * (do_read[0] & do_read[1]));
@@ -389,9 +390,9 @@ cmd_swap(void) {
err_if(!(goodChecksum(0) || goodChecksum(1)));
errno = 0;
- gbe[0] ^= gbe[1];
- gbe[1] ^= gbe[0];
- gbe[0] ^= gbe[1];
+ uint8_t *chg = gbe[0];
+ gbe[0] = gbe[1];
+ gbe[1] = chg;
nvmPartChanged[0] = nvmPartChanged[1] = 1;
}
@@ -459,7 +460,7 @@ writeGbe_part(int p)
void
swap(int partnum)
{
- uint8_t *n = (uint8_t *) gbe[partnum];
+ uint8_t *n = gbe[partnum];
for (size_t w = NVM_SIZE * ((uint8_t *) &e)[0], x = 1;
w < NVM_SIZE; w += 2, x += 2) {