]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix bitwise logic
authorRoy Marples <roy@marples.name>
Wed, 23 Nov 2011 10:53:53 +0000 (10:53 +0000)
committerRoy Marples <roy@marples.name>
Wed, 23 Nov 2011 10:53:53 +0000 (10:53 +0000)
dhcpcd.c
if-bsd.c

index 9449d0137d57639e8c255641fd39494445e04bc4..59a18ce416f46dd23d5535af2cdc4d776c63c6e3 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -897,7 +897,7 @@ handle_carrier(int action, int flags, const char *ifname)
        }
        if (carrier == -1)
                syslog(LOG_ERR, "%s: carrier_status: %m", ifname);
-       else if (carrier == 0 || !(iface->flags & (IFF_UP || IFF_RUNNING))) {
+       else if (carrier == 0 || ~iface->flags & (IFF_UP | IFF_RUNNING)) {
                if (iface->carrier != LINK_DOWN) {
                        iface->carrier = LINK_DOWN;
                        syslog(LOG_INFO, "%s: carrier lost", iface->name);
@@ -905,7 +905,7 @@ handle_carrier(int action, int flags, const char *ifname)
                        delete_timeouts(iface, start_expire, NULL);
                        drop_config(iface, "NOCARRIER");
                }
-       } else if (carrier == 1 && (iface->flags & (IFF_UP || IFF_RUNNING))) {
+       } else if (carrier == 1 && !(~iface->flags & (IFF_UP | IFF_RUNNING))) {
                if (iface->carrier != LINK_UP) {
                        iface->carrier = LINK_UP;
                        syslog(LOG_INFO, "%s: carrier acquired", iface->name);
index 6c8c968f2726a972d8cb944c8cc82d4b8fdb527a..c286749548e3e6127c164c843afbc6db75de95a4 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -369,8 +369,8 @@ manage_link(int fd)
                                        len = -1;
                                        break;
                                default:
-                                       len = ifm->ifm_flags &
-                                           (IFF_UP || IFF_RUNNING) ? 1 : -1;
+                                       len = ~ifm->ifm_flags &
+                                           (IFF_UP | IFF_RUNNING) ? -1 : 1;
                                        break;
                                }
                                handle_carrier(len, ifm->ifm_flags, ifname);