]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Minor optimisation and fix to prior.
authorRoy Marples <roy@marples.name>
Thu, 10 Oct 2019 11:00:46 +0000 (12:00 +0100)
committerRoy Marples <roy@marples.name>
Thu, 10 Oct 2019 11:00:46 +0000 (12:00 +0100)
src/if.c

index ff0e4c4d46fb80122e84f39cee6fa08a94317fd8..459af3afd5ae1d6c6c0896dfe9acfe78fc5bac65 100644 (file)
--- 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