From edca6c2cd3a22f8f215e99f50dd50ca4e1c00f6d Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 6 Mar 2026 17:35:00 +0000 Subject: util/nvmutil: tidy up set_mac_nib Signed-off-by: Leah Rowe --- util/nvmutil/nvmutil.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'util') 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? */ /* -- cgit v1.2.1