util/nvmutil: tidy up set_mac_nib

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-03-06 17:35:00 +00:00
parent 123e77d07f
commit edca6c2cd3

View File

@@ -401,12 +401,15 @@ static void
set_mac_nib(int mac_pos, int nib)
{
uint8_t h;
int byte = mac_pos / 3;
int byte;
int shift;
if ((h = hextonum(mac[mac_pos + nib])) > 15)
err(EINVAL, "Invalid character '%c'",
mac[mac_pos + nib]);
byte = mac_pos / 3;
/* If random, ensure that local/unicast bits are set */
if ((byte == 0) && (nib == 1) &&
((mac[mac_pos + nib] == '?') ||
@@ -421,7 +424,7 @@ set_mac_nib(int mac_pos, int nib)
* we store the MAC address in reverse order
* per 2-byte word (there are 3 of these).
*/
int shift = (byte & 1) << 3; /* left or right byte? */
shift = (byte & 1) << 3; /* left or right byte? */
shift |= (nib ^ 1) << 2; /* left or right nib? */
/*