From: Roy Marples Date: Wed, 14 May 2008 12:19:05 +0000 (+0000) Subject: Prettify code a little. X-Git-Tag: v4.0.2~405 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=343c1ae64197ffe81aed083514b930c65af7931a;p=thirdparty%2Fdhcpcd.git Prettify code a little. --- diff --git a/bpf-filter.h b/bpf-filter.h index 17ba8453..59118039 100644 --- a/bpf-filter.h +++ b/bpf-filter.h @@ -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]); diff --git a/config.h b/config.h index 5d295904..5ee756fc 100644 --- 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 diff --git a/socket.c b/socket.c index e0012253..6ae104f2 100644 --- 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;