]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Prettify code a little.
authorRoy Marples <roy@marples.name>
Wed, 14 May 2008 12:19:05 +0000 (12:19 +0000)
committerRoy Marples <roy@marples.name>
Wed, 14 May 2008 12:19:05 +0000 (12:19 +0000)
bpf-filter.h
config.h
socket.c

index 17ba8453ee3e616601c214256dab3bcfae6c44fe..5911803937045fed469fa960dafa882c99b6b7d3 100644 (file)
@@ -52,6 +52,9 @@ static struct bpf_insn dhcp_bpf_filter [] = {
        /* Otherwise, drop it. */
        BPF_STMT (BPF_RET + BPF_K, 0),
 };
+static const size_t dhcp_bpf_filter_len =
+    sizeof(dhcp_bpf_filter) / sizeof(dhcp_bpf_filter[0]);
+
 
 /* This, however, is mine */
 static struct bpf_insn arp_bpf_filter [] = {
@@ -69,3 +72,5 @@ static struct bpf_insn arp_bpf_filter [] = {
        /* Otherwise, drop it. */
        BPF_STMT (BPF_RET + BPF_K, 0),
 };
+static const size_t arp_bpf_filter_len =
+    sizeof(arp_bpf_filter) / sizeof(arp_bpf_filter[0]);
index 5d2959042892f47f15cc56a398fd88a49e2bcd80..5ee756fc0e9c791d53f0497e285d3eb0abaf90cc 100644 (file)
--- a/config.h
+++ b/config.h
@@ -76,4 +76,6 @@
 #define LEASEFILE              DBDIR "/" PACKAGE "-%s.lease"
 #define PIDFILE                        RUNDIR "/" PACKAGE "-%s.pid"
 
+#define UNCONST(a)     ((void *)(unsigned long)(const void *)(a))
+
 #endif
index e00122537d6d602e3ec679b9e56618e0a5be0492..6ae104f2d7a8a8392761438a7dfd46c36cb0f1e9 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -116,10 +116,10 @@ open_socket(struct interface *iface, int protocol)
        memset(&pf, 0, sizeof(pf));
        if (protocol == ETHERTYPE_ARP) {
                pf.filter = arp_bpf_filter;
-               pf.len = sizeof(arp_bpf_filter) / sizeof(arp_bpf_filter[0]);
+               pf.len = arp_bpf_filter_len;
        } else {
                pf.filter = dhcp_bpf_filter;
-               pf.len = sizeof(dhcp_bpf_filter) / sizeof(dhcp_bpf_filter[0]);
+               pf.len = dhcp_bpf_filter_len;
        }
        if (setsockopt(s, SOL_SOCKET, SO_ATTACH_FILTER, &pf, sizeof(pf)) != 0)
                goto eexit;