diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-07 01:20:42 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-07 01:21:29 +0000 |
| commit | 7e88f53e998961a95247f3096cd30b4255b5da45 (patch) | |
| tree | 6cd178bf06261427aba50f8679dc04fb64caf539 /util/nvmutil/nvmutil.c | |
| parent | c02f3166bbaaad5692426171bc0d84e9e98c8f41 (diff) | |
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>
Diffstat (limited to 'util/nvmutil/nvmutil.c')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 82a73ef4..48011fa1 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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); |
