util/nvmutil: tidy up set_mac_byte

send the mac address byte directly to check_mac_separator

functionally identicaly, but cleaner, and uses
multiplication instead of division (faster).

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-07 01:20:42 +00:00
parent c02f3166bb
commit 7e88f53e99
+5 -4
View File
@@ -464,13 +464,13 @@ cmd_setmac(void)
static void
parse_mac_string(void)
{
size_t mac_str_pos;
size_t mac_byte;
if (strlen(mac_str) != 17)
err(EINVAL, "MAC address is the wrong length");
for (mac_str_pos = 0; mac_str_pos < 16; mac_str_pos += 3)
set_mac_byte(mac_str_pos);
for (mac_byte = 0; mac_byte < 6; mac_byte++)
set_mac_byte(mac_byte);
if ((mac_buf[0] | mac_buf[1] | mac_buf[2]) == 0)
err(EINVAL, "Must not specify all-zeroes MAC address");
@@ -480,8 +480,9 @@ parse_mac_string(void)
}
static void
set_mac_byte(size_t mac_str_pos)
set_mac_byte(size_t mac_byte)
{
size_t mac_str_pos = mac_byte * 3;
size_t mac_nib_pos;
check_mac_separator(mac_str_pos);