From: Roy Marples Date: Wed, 23 Nov 2011 10:53:53 +0000 (+0000) Subject: Fix bitwise logic X-Git-Tag: v5.5.0~21 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e896947f2c200c2824b2a0d5eb1cf34e219e916a;p=thirdparty%2Fdhcpcd.git Fix bitwise logic --- diff --git a/dhcpcd.c b/dhcpcd.c index 9449d013..59a18ce4 100644 --- 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); diff --git a/if-bsd.c b/if-bsd.c index 6c8c968f..c2867495 100644 --- 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);