mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-11 05:52:36 +02:00
util/nvmutil: make setWord a macro
253 sloccount on nvmutil.c now, versus 258 Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+5
-11
@@ -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
|
||||
@@ -260,13 +261,6 @@ validChecksum(int partnum)
|
||||
return (errno = ECANCELED) & 0;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user