summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-01-28 22:40:01 +0000
committerLeah Rowe <leah@libreboot.org>2023-01-28 22:40:01 +0000
commit031a0b553ba15e495ce1696ea19a606b239909e4 (patch)
tree6c9efe1b81880c704b6ebb1789752c4eca815b31 /util/nvmutil/nvmutil.c
parent257eedca0c729ae7341733306bc87d29b8113c28 (diff)
util/nvmutil: setWord(): declare variables first
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index c8b866a9..687659a5 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -411,13 +411,17 @@ word(int pos16, int partnum)
void
setWord(int pos16, int partnum, uint16_t val16)
{
+ uint8_t val8[2], *nbuf;
+ uint16_t pos8;
+
gbeWriteAttempted = 1;
if (word(pos16, partnum) == val16)
return;
- uint8_t *nbuf = (uint8_t *) gbe[partnum];
- uint8_t val8[2] = {(uint8_t) (val16 & 0xff), (uint8_t) (val16 >> 8)};
- uint16_t pos8 = pos16 << 1;
+ nbuf = (uint8_t *) gbe[partnum];
+ val8[0] = (uint8_t) (val16 & 0xff);
+ val8[1] = (uint8_t) (val16 >> 8);
+ pos8 = pos16 << 1;
nbuf[pos8] = val8[0];
nbuf[pos8 + 1] = val8[1];