From dfd2abf17313e7aa99cd2e0606d66f029b51be85 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Thu, 10 Oct 2019 12:00:46 +0100 Subject: [PATCH] Minor optimisation and fix to prior. --- src/if.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/if.c b/src/if.c index ff0e4c4d..459af3af 100644 --- a/src/if.c +++ b/src/if.c @@ -312,6 +312,7 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, struct if_head *ifs; struct interface *ifp; struct if_spec spec; + bool if_noconf; #ifdef AF_LINK const struct sockaddr_dl *sdl; #ifdef IFLR_ACTIVE @@ -412,12 +413,12 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, continue; } -#define IF_NOCONF ((argc == 0 || argc == -1) && ctx->ifac == 0 && \ - !if_hasconf(ctx, spec.devname)) + if_noconf = ((argc == 0 || argc == -1) && ctx->ifac == 0 && + !if_hasconf(ctx, spec.devname)); /* Don't allow loopback or pointopoint unless explicit. * Don't allow some reserved interface names unless explicit. */ - if (IF_NOCONF) { + if (if_noconf) { if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT) || if_ignore(ctx, spec.devname)) active = IF_INACTIVE; @@ -465,16 +466,14 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #endif case IFT_PPP: /* Don't allow unless explicit */ - if ((argc == 0 || argc == -1) && - ctx->ifac == 0 && active && - !if_hasconf(ctx, ifp->name)) - { + if (if_noconf) { logdebugx("%s: ignoring due to" " interface type and" " no config", ifp->name); active = IF_INACTIVE; } + __fallthrough; /* appease gcc */ /* FALLTHROUGH */ #ifdef IFT_L2VLAN case IFT_L2VLAN: /* FALLTHROUGH */ @@ -482,7 +481,6 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #ifdef IFT_L3IPVLAN case IFT_L3IPVLAN: /* FALLTHROUGH */ #endif - /* FALLTHROUGH */ case IFT_ETHER: ifp->family = ARPHRD_ETHER; break; @@ -498,11 +496,11 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, #endif default: /* Don't allow unless explicit */ - if (IF_NOCONF) + if (if_noconf) active = IF_INACTIVE; if (active) logwarnx("%s: unsupported" - " interface type %.2x", + " interface type 0x%.2x", ifp->name, sdl->sdl_type); /* Pretend it's ethernet */ ifp->family = ARPHRD_ETHER; @@ -565,7 +563,7 @@ if_discover(struct dhcpcd_ctx *ctx, struct ifaddrs **ifaddrs, default: if (active) logwarnx("%s: unsupported" - " interface family %.2x", + " interface family 0x%.2x", ifp->name, ifp->family); break; #endif -- 2.47.2