diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-03-06 21:06:58 +0000 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-03-06 21:06:58 +0000 |
| commit | 040eee4607d083ee7a1a340ab62e4b36fe2e1e72 (patch) | |
| tree | 8ee72ad4adb4c1e626a7630cfb254c5be1089de4 | |
| parent | 6b924787bed8c29d22ae66f74fbe3db90b25412a (diff) | |
util/nvmutil: tidy up set_mac_nib
simplify it again
Signed-off-by: Leah Rowe <leah@libreboot.org>
| -rw-r--r-- | util/nvmutil/nvmutil.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c index ff74403e..f39cd65f 100644 --- a/util/nvmutil/nvmutil.c +++ b/util/nvmutil/nvmutil.c @@ -468,10 +468,7 @@ set_mac_nib(size_t mac_str_pos, size_t mac_nib_pos) uint8_t mac_ch; size_t mac_byte_pos; - - size_t mac_buf_word_pos; - size_t mac_buf_byte_pos; - size_t mac_buf_nib_pos; + size_t mac_word_left_shift; if ((mac_ch = hextonum(mac_str[mac_str_pos + mac_nib_pos])) > 15) err(EINVAL, "Invalid character '%c'", @@ -496,15 +493,15 @@ set_mac_nib(size_t mac_str_pos, size_t mac_nib_pos) * * Later code using the MAC string will handle this. */ - mac_buf_word_pos = mac_byte_pos >> 1; - mac_buf_byte_pos = (mac_byte_pos & 1) << 3; /* left or right byte? */ - mac_buf_nib_pos = (mac_nib_pos ^ 1) << 2; /* left or right nib? */ + mac_word_left_shift = + ((mac_byte_pos & 1) << 3) /* left or right byte? */ + | ((mac_nib_pos ^ 1) << 2); /* left or right nib? */ /* * Now we can shift properly, OR'ing the result: */ - mac_buf[mac_buf_word_pos] |= (uint16_t)mac_ch << - (mac_buf_byte_pos | mac_buf_nib_pos); + mac_buf[mac_byte_pos >> 1] |= + (uint16_t)mac_ch << mac_word_left_shift; } static uint8_t |
