util/nvmutil: inline pos calculation on word()

we don't need a whole function. i previously did it
for clarity, but simply setting a variable all in
one line is totally fine.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-06 13:47:16 +00:00
parent d89d14e911
commit 95b294db05
+2 -12
View File
@@ -43,7 +43,6 @@ static void cmd_swap(void);
static int good_checksum(int);
static uint16_t word(size_t, int);
static void set_word(size_t, int, uint16_t);
static size_t get_word_pos(size_t, int);
static void check_bound(size_t, int);
static void write_gbe(void);
static void write_gbe_part(int);
@@ -620,7 +619,7 @@ word(size_t pos16, int p)
size_t pos;
check_bound(pos16, p);
pos = get_word_pos(pos16, p);
pos = (pos16 << 1) + ((size_t)p * SIZE_4KB);
return (uint16_t)buf[pos] | ((uint16_t)buf[pos + 1] << 8);
}
@@ -631,7 +630,7 @@ set_word(size_t pos16, int p, uint16_t val16)
size_t pos;
check_bound(pos16, p);
pos = get_word_pos(pos16, p);
pos = (pos16 << 1) + ((size_t)p * SIZE_4KB);
buf[pos] = (uint8_t)(val16 & 0xff);
buf[pos + 1] = (uint8_t)(val16 >> 8);
@@ -639,15 +638,6 @@ set_word(size_t pos16, int p, uint16_t val16)
part_modified[p] = 1;
}
static size_t
get_word_pos(size_t pos16, int p)
{
size_t off = SIZE_4KB * p;
size_t pos = (pos16 << 1) + off;
return pos;
}
static void
check_bound(size_t c, int p)
{