mb/siemens/mc_apl1: Simplify is_mac_adr_valid() logic
A MAC address that is neither 00:00:00:00:00:00 nor ff:ff:ff:ff:ff:ff is considered valid. Instead of using a temporary buffer and memcmp(), use a single loop that exits as soon as the MAC cannot possibly be invalid. Change-Id: I2b15b510092860fbbefd150c9060da38aeb13311 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47405 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Werner Zeh <werner.zeh@siemens.com> Reviewed-by: Mario Scheithauer <mario.scheithauer@siemens.com> Reviewed-by: Uwe Poeche <uwe.poeche@siemens.com>
This commit is contained in:
parent
c19a9a5278
commit
afb60e7112
@ -35,15 +35,13 @@
|
|||||||
*/
|
*/
|
||||||
static uint8_t is_mac_adr_valid(uint8_t mac[MAC_ADDR_LEN])
|
static uint8_t is_mac_adr_valid(uint8_t mac[MAC_ADDR_LEN])
|
||||||
{
|
{
|
||||||
uint8_t buf[MAC_ADDR_LEN];
|
for (size_t i = 0; i < MAC_ADDR_LEN; i++) {
|
||||||
|
if (mac[i] != 0x00 && mac[i] != 0xff)
|
||||||
memset(buf, 0, sizeof(buf));
|
return 1;
|
||||||
if (!memcmp(buf, mac, sizeof(buf)))
|
if (mac[i] != mac[0])
|
||||||
return 0;
|
return 1;
|
||||||
memset(buf, 0xff, sizeof(buf));
|
}
|
||||||
if (!memcmp(buf, mac, sizeof(buf)))
|
return 0;
|
||||||
return 0;
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief This function will search for a MAC address which can be assigned
|
/** \brief This function will search for a MAC address which can be assigned
|
||||||
|
Loading…
x
Reference in New Issue
Block a user