util/nvmutil: make swap() a bit clearer

don't sizecode. show the individual steps clearly.

Signed-off-by: Leah Rowe <leah@libreboot.org>
master
Leah Rowe 2025-01-27 04:09:09 +00:00
parent 06f30b9543
commit dcfde2e318
1 changed files with 6 additions and 2 deletions

View File

@ -441,6 +441,10 @@ swap(int partnum) /* swaps bytes in words, not pointers. */
size_t w, x; size_t w, x;
uint8_t *n = (uint8_t *) gbe[partnum]; uint8_t *n = (uint8_t *) gbe[partnum];
for (w = nf * ((uint8_t *) &e)[0], x = 1; w < NVM_SIZE; w += 2, x += 2) for (w = nf * ((uint8_t *) &e)[0], x = 1; w < NVM_SIZE;
n[w] ^= n[x], n[x] ^= n[w], n[w] ^= n[x]; w += 2, x += 2) {
n[w] ^= n[x];
n[x] ^= n[w];
n[w] ^= n[x];
}
} }