diff options
author | Angel Pons <th3fanbus@gmail.com> | 2020-11-10 18:17:10 +0100 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2020-11-30 07:53:02 +0000 |
commit | a9db4bd9899feb8f6b464a9ee2cc88c4ed91d6fc (patch) | |
tree | 2591c4709342704756543dbedf7a49d685406cff /src | |
parent | c97a1c0ac8e3fe2900eb296a7a2d05578d358bf0 (diff) | |
download | coreboot-a9db4bd9899feb8f6b464a9ee2cc88c4ed91d6fc.tar.xz |
mb/siemens/mc_apl1/mainboard.c: Refactor loop body
Break down multi-line compound conditions into multiple if-statements,
and leverage `continue` statements to avoid nesting multiple checks.
Change-Id: I5edc279a57e25a0dff1a4b42f0bbc88c0659b476
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/47403
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Tested-by: siemens-bot
Reviewed-by: Werner Zeh <werner.zeh@siemens.com>
Reviewed-by: Uwe Poeche <uwe.poeche@siemens.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/mainboard/siemens/mc_apl1/mainboard.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/mainboard/siemens/mc_apl1/mainboard.c b/src/mainboard/siemens/mc_apl1/mainboard.c index 0d93563ccf..5b8f70f353 100644 --- a/src/mainboard/siemens/mc_apl1/mainboard.c +++ b/src/mainboard/siemens/mc_apl1/mainboard.c @@ -85,19 +85,18 @@ enum cb_err mainboard_get_mac_address(struct device *dev, uint8_t mac[6]) /* Open main hwinfo block */ if (hwilib_find_blocks("hwinfo.hex") != CB_SUCCESS) return CB_ERR; - /* Now try to find a valid MAC address in hwinfo for this mapping.*/ + /* Now try to find a valid MAC address in hwinfo for this mapping. */ for (i = 0; i < MAX_NUM_MAPPINGS; i++) { - if ((hwilib_get_field(XMac1Mapping + i, buf, 16) == 16) && - !(memcmp(buf, mapping, chain_len + 4))) { + if (hwilib_get_field(XMac1Mapping + i, buf, 16) != 16) + continue; + if (memcmp(buf, mapping, chain_len + 4)) + continue; /* There is a matching mapping available, get MAC address. */ - if ((hwilib_get_field(XMac1 + i, mac, 6) == 6) && - (is_mac_adr_valid(mac))) { + if (hwilib_get_field(XMac1 + i, mac, 6) == 6) { + if (is_mac_adr_valid(mac)) return CB_SUCCESS; - } else { - return CB_ERR; - } - } else - continue; + } + return CB_ERR; } /* No MAC address found for */ return CB_ERR; |