diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-06 17:35:00 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-06 17:35:00 +0000 |
| commit | edca6c2cd3a22f8f215e99f50dd50ca4e1c00f6d (patch) | |
| tree | 85c41d058a25c2aaae916bf391fb6ed1fdcea6ee /util/nvmutil | |
| parent | 123e77d07f54e2b20ff213a761d36ca008a328dd (diff) | |
util/nvmutil: tidy up set_mac_nib
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util/nvmutil')
| -rw-r--r-- | util/nvmutil/nvmutil.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index 43afe9d1..3b97b5c1 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -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? */ /* |
