util/nvmutil: only swap/copy if checksum is valid
in practise, the file was never written unless the checksum was valid, but in the same of sloccount reduction i made it do the swap/copy before checking. while functionally ok, it never sat right with me. this is one example of where sloc count doesn't mean everything. code correctness is critical Signed-off-by: Leah Rowe <leah@libreboot.org>fsdg20230625
parent
9aa34f1e20
commit
b49da12dad
|
@ -205,16 +205,18 @@ cmd_brick(void)
|
|||
void
|
||||
cmd_swap(void)
|
||||
{
|
||||
xorswap(gbe[0], gbe[1]); /* speedhack: swap ptr, not words */
|
||||
gbeFileModified = nvmPartModified[0] = nvmPartModified[1]
|
||||
= validChecksum(1) | validChecksum(0);
|
||||
if (gbeFileModified)
|
||||
xorswap(gbe[0], gbe[1]); /* speedhack: swap ptr, not words */
|
||||
}
|
||||
|
||||
void
|
||||
cmd_copy(void)
|
||||
{
|
||||
gbe[part ^ 1] = gbe[part]; /* speedhack: copy ptr, not words */
|
||||
gbeFileModified = nvmPartModified[part ^ 1] = validChecksum(part);
|
||||
if (gbeFileModified)
|
||||
gbe[part ^ 1] = gbe[part]; /* speedhack: copy ptr, not words */
|
||||
}
|
||||
|
||||
int
|
||||
|
|
Loading…
Reference in New Issue