]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Optimize bitwise useage a little.
authorRoy Marples <roy@marples.name>
Wed, 23 Nov 2011 11:59:53 +0000 (11:59 +0000)
committerRoy Marples <roy@marples.name>
Wed, 23 Nov 2011 11:59:53 +0000 (11:59 +0000)
dhcp.c
if-bsd.c

diff --git a/dhcp.c b/dhcp.c
index 2def24894359d487c5bf1cf5ecd71ad7d1faf091..def4c758ffc9a2756f221c3e2e3e981f097ddf2b 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -1,6 +1,6 @@
 /* 
  * dhcpcd - DHCP client daemon
- * Copyright (c) 2006-2010 Roy Marples <roy@marples.name>
+ * Copyright (c) 2006-2011 Roy Marples <roy@marples.name>
  * All rights reserved
 
  * Redistribution and use in source and binary forms, with or without
@@ -266,18 +266,17 @@ valid_length(uint8_t option, int dl, int *type)
                        *type = opt->type;
 
                if (opt->type == 0 ||
-                   opt->type & STRING ||
-                   opt->type & RFC3442)
+                   opt->type & (STRING | RFC3442))
                        return 0;
 
                sz = 0;
-               if (opt->type & UINT32 || opt->type & IPV4)
+               if (opt->type & (UINT32 | IPV4))
                        sz = sizeof(uint32_t);
                if (opt->type & UINT16)
                        sz = sizeof(uint16_t);
                if (opt->type & UINT8)
                        sz = sizeof(uint8_t);
-               if (opt->type & IPV4 || opt->type & ARRAY)
+               if (opt->type & (IPV4 | ARRAY))
                        return dl % sz;
                return (dl == sz ? 0 : -1);
        }
index c286749548e3e6127c164c843afbc6db75de95a4..420715e7453234d63f0e2ae67ddae51c29e55891 100644 (file)
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -376,9 +376,8 @@ manage_link(int fd)
                                handle_carrier(len, ifm->ifm_flags, ifname);
                                break;
                        case RTM_DELETE:
-                               if (!(rtm->rtm_addrs & RTA_DST) ||
-                                   !(rtm->rtm_addrs & RTA_GATEWAY) ||
-                                   !(rtm->rtm_addrs & RTA_NETMASK))
+                               if (~rtm->rtm_addrs &
+                                   (RTA_DST | RTA_GATEWAY | RTA_NETMASK))
                                        break;
                                if (rtm->rtm_pid == getpid())
                                        break;