[U-Boot] [PATCH 11/14] fdt: eth_fixup: improve error catching/reduce identation
Olliver Schinagl
oliver at schinagl.nl
Fri Nov 25 16:30:29 CET 2016
Currently when checking for an error in ethernet aliases in the fdt, we
only check for the error case -1. It is safer to ignore anything < 0.
By rearranging logic a bit we can now also reduce identation.
Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
common/fdt_support.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 20a3dd9..c34a13c 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -495,20 +495,20 @@ void fdt_fixup_ethernet(void *fdt)
path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
if (!strncmp(name, "ethernet", len)) {
i = trailing_strtol(name);
- if (i != -1) {
- if (i == 0)
- strcpy(mac, "ethaddr");
- else
- sprintf(mac, "eth%daddr", i);
- } else {
+ if (i < 0)
continue;
- }
+
+ if (i == 0)
+ strcpy(mac, "ethaddr");
+ else
+ sprintf(mac, "eth%daddr", i);
+
fdt_eth_addr = getenv(mac);
- if (!fdt_eth_addr)
+ if (fdt_eth_addr)
+ eth_parse_enetaddr(fdt_eth_addr, mac_addr);
+ else
continue;
- eth_parse_enetaddr(fdt_eth_addr, mac_addr);
-
do_fixup_by_path(fdt, path, "mac-address",
&mac_addr, 6, 0);
do_fixup_by_path(fdt, path, "local-mac-address",
--
2.10.2
More information about the U-Boot
mailing list