From a7cc8143a7f5ef492b6081457d18e351a68c9255 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Tue, 3 Mar 2026 01:18:23 +0000 Subject: util/nvmutil: cmd copy/swap: use word/setWord this means that we make use of the boundary checks. it's just a safer way of handling these functions. Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'util/nvmutil/nvmutil.c') diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 6f0bc17d..ab33ac24 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -356,8 +356,8 @@ void cmd_copy(void) { err_if(!goodChecksum(part)); - for (int c = 0; c < SIZE_4KB; c++) - gbe[part ^ 1][c] = gbe[part][c]; + for (int c = 0; c < (SIZE_4KB >> 1); c++) + setWord(c, part ^ 1, word(c, part)); } void @@ -365,10 +365,10 @@ cmd_swap(void) { err_if(!(goodChecksum(0) || goodChecksum(1))); errno = 0; - for (int c = 0; c < SIZE_4KB; c++) { - uint8_t chg = gbe[0][c]; - gbe[0][c] = gbe[1][c]; - gbe[1][c] = chg; + for (int c = 0; c < (SIZE_4KB >> 1); c++) { + uint16_t chg = word(c, 0); + setWord(c, 0, word(c, 1)); + setWord(c, 1, chg); } } -- cgit v1.2.1