diff options
author | Leah Rowe <leah@libreboot.org> | 2025-01-27 05:07:27 +0000 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2025-01-27 05:08:17 +0000 |
commit | 83601aa524b6772f4310f257408f62ace19a00d6 (patch) | |
tree | 6701942ec464744989b86485b2d4cac2eae4c581 | |
parent | 3e86bf5ce25881dcc50149be62ccc778e640833e (diff) |
util/nvmutil: reset errno if any MAC updated
instead of setting errno in the for loop, set a variable
declaring that the mac was updated, and reset errno based
on that.
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r-- | util/nvmutil/nvmutil.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index b7174133..f32350ba 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -246,18 +246,22 @@ readGbe(void) void cmd_setmac(void) { + int mac_updated = 0; parseMacString(strMac, mac); for (int partnum = 0; partnum < 2; partnum++) { if (!goodChecksum(part = partnum)) continue; - errno = 0; + mac_updated = 1; for (int w = 0; w < 3; w++) /* write MAC to gbe part */ setWord(w, partnum, mac[w]); cmd_setchecksum(); /* MAC updated; need valid checksum */ } + + if (mac_updated) + errno = 0; /* reset in case one of the checksums failed */ } /* parse MAC string, write to char buffer */ |