summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-19 16:18:13 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-19 16:18:13 +0100
commit231015ef89b194056b9d5eeef3d859b01167990b (patch)
treeaca5cf7d08540478bf1a6d1e29b23f96dd0fff5c /util
parentd9bed115018bae46ca6b20a9f8f55ee434dd8cfa (diff)
util/nvmutil: make setWord a macro
253 sloccount on nvmutil.c now, versus 258 Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r--util/nvmutil/nvmutil.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 36ef6b01..79132a12 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -26,7 +26,6 @@ void cmd_setchecksum(void);
void cmd_brick(void);
void cmd_copy(void);
int validChecksum(int partnum);
-void setWord(int pos16, int partnum, uint16_t val16);
void xorswap_buf(int partnum);
void writeGbeFile(void);
@@ -62,12 +61,14 @@ void (*cmd)(void) = NULL;
#define err_if(x) if (x) err(ERR(), "%s", filename)
#define xopen(f,l,p) if (opendir(l) != NULL) err(errno = EISDIR, "%s", l); \
- if ((f = open(l, p)) == -1) err(ERR(), "%s", l); \
- if (fstat(f, &st) == -1) err(ERR(), "%s", l)
+ if ((f = open(l, p)) == -1) err(ERR(), "%s", l); \
+ if (fstat(f, &st) == -1) err(ERR(), "%s", l)
#define handle_endianness(r) if (((uint8_t *) &endian)[0] ^ 1) xorswap_buf(r)
#define xorswap(x, y) x ^= y, y ^= x, x ^= y
#define word(pos16, partnum) buf16[pos16 + (partnum << 11)]
+#define setWord(pos16, p, val16) if ((gbeFileModified = 1) && \
+ word(pos16, p) != val16) nvmPartModified[p] = 1 | (word(pos16, p) = val16)
int
main(int argc, char *argv[])
@@ -238,7 +239,7 @@ void
cmd_brick(void)
{
if (validChecksum(part))
- setWord(0x3F, part, (word(0x3F, part)) ^ 0xFF);
+ setWord(0x3F, part, ((word(0x3F, part)) ^ 0xFF));
}
void
@@ -261,13 +262,6 @@ validChecksum(int partnum)
}
void
-setWord(int pos16, int partnum, uint16_t val16)
-{
- if ((gbeFileModified = 1) && word(pos16, partnum) != val16)
- nvmPartModified[partnum] = 1 | (word(pos16, partnum) = val16);
-}
-
-void
xorswap_buf(int partnum)
{
uint8_t *nbuf = (uint8_t *) gbe[partnum];