summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-06-01 06:58:30 +0100
committerLeah Rowe <leah@libreboot.org>2023-06-01 06:58:30 +0100
commit1f548604019c1745c2800a6a5e9f64b29700972f (patch)
treebb311c68c76e1cf0b82265b62bc563816ac1f96b /util/nvmutil
parent8f1e6d792f9abfe7fa5e9865f894cdcbefc5e394 (diff)
util/nvmutil: minor code cleanup
Make word() a macro, simplify err_if(). Could also make setWord() a macro if I forego certain optimisations, but I'll leave it as-is. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index e75ba650..319daf2a 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -52,7 +52,6 @@ void cmd_brick(void);
void cmd_swap(void);
void cmd_copy(void);
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, size_t nw);
@@ -67,6 +66,8 @@ void err_if(int condition);
#define SIZE_4KB 0x1000
#define SIZE_8KB 0x2000
+#define word(pos16, partnum) (buf16[pos16 + (partnum << 11)])
+
uint16_t buf16[SIZE_4KB];
uint8_t *buf;
size_t gbe[2];
@@ -322,12 +323,6 @@ validChecksum(int partnum)
return (errno = ECANCELED) & 0;
}
-uint16_t
-word(int pos16, int partnum)
-{
- return buf16[pos16 + (partnum << 11)];
-}
-
void
setWord(int pos16, int partnum, uint16_t val16)
{
@@ -397,9 +392,6 @@ xunveil(const char *path, const char *permissions)
void
err_if(int condition)
{
- if (!condition)
- return;
- if (!errno)
- errno = ECANCELED;
- err(errno, NULL);
+ if (condition)
+ err(errno = errno ? errno : ECANCELED, NULL);
}