summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-02 17:33:34 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-02 17:34:37 +0000
commit4e7d48b5c54a3a9132dfa04ab783688322ec87a9 (patch)
tree1478d5dc5ab95aff9a42110b64be14e1436cd128 /util
parent8707695184bfef642ed8640f6cde7329a8eafe3d (diff)
util/nvmutil: make word/setWord a function
having this as a macro makes the code quite brittle. better to have it as a function. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 1ba3dc09..84b44aa6 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -20,9 +20,10 @@ void cmd_setchecksum(void), cmd_brick(void), swap(int partnum), writeGbe(void),
parseMacString(const char *strMac, uint16_t *mac), cmd_swap(void),
openFiles(const char *path), cmd_copy(void), writeGbe_part(int),
readGbe_part(int), usage(char*), set_io_flags(int, char **),
- set_cmd(int, char **);
+ set_cmd(int, char **), setWord(int, int, uint16_t);
int goodChecksum(int partnum);
uint8_t hextonum(char chs), rhex(void);
+uint16_t word(int, int);
#ifdef __OpenBSD__
void block_unveil(void);
@@ -72,10 +73,6 @@ void (*cmd)(void) = NULL;
err(SET_ERR(ECANCELED), "%s", l); \
if (fstat(f, &st) == -1) err(SET_ERR(ECANCELED), "%s", l)
-#define word(pos16, partnum) ((uint16_t *) gbe[partnum])[pos16]
-#define setWord(pos16, p, val16) if (word(pos16, p) != val16) \
- nvmPartChanged[p] = 1 | (word(pos16, p) = val16)
-
int
main(int argc, char *argv[])
{
@@ -405,6 +402,21 @@ goodChecksum(int partnum)
return 0;
}
+uint16_t
+word(int pos16, int p)
+{
+ return ((uint16_t *) gbe[p])[pos16];
+}
+
+void
+setWord(int pos16, int p, uint16_t val16)
+{
+ if (((uint16_t *) gbe[p])[pos16] != val16) {
+ nvmPartChanged[p] = 1;
+ ((uint16_t *) gbe[p])[pos16] = val16;
+ }
+}
+
void
writeGbe(void)
{