summaryrefslogtreecommitdiff
path: root/util/nvmutil
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-03-03 01:18:23 +0000
committerLeah Rowe <leah@libreboot.org>2026-03-03 01:18:23 +0000
commita7cc8143a7f5ef492b6081457d18e351a68c9255 (patch)
tree84bfd294b1ec468b242481e7700bc55e55495bae /util/nvmutil
parent566ae72ca3c86b31b7379204877cdbd726f61b10 (diff)
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 <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
-rw-r--r--util/nvmutil/nvmutil.c12
1 files changed, 6 insertions, 6 deletions
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);
}
}