From 031a0b553ba15e495ce1696ea19a606b239909e4 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 28 Jan 2023 22:40:01 +0000 Subject: util/nvmutil: setWord(): declare variables first --- util/nvmutil/nvmutil.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'util/nvmutil') 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]; -- cgit v1.2.1