From 1dc6074b62f8141e9848bbaee7275e5752507e8f Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Sat, 29 Jun 2013 20:35:13 +0200 Subject: Fix int/long discrepancy * device/net_io.c (bpf_match): Make the `keys' parameter a pointer to unsigned int instead of unsigned long. (bpf_do_filter): Make `A', `B' and `mem' unsigned ints instead of unsigned longs. Also turn long casts into int casts. --- device/net_io.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'device/net_io.c') diff --git a/device/net_io.c b/device/net_io.c index 4ebf996..fd71c02 100644 --- a/device/net_io.c +++ b/device/net_io.c @@ -394,7 +394,7 @@ int net_add_q_info (ipc_port_t rcv_port); int bpf_match ( net_hash_header_t hash, int n_keys, - unsigned long *keys, + unsigned int *keys, net_hash_entry_t **hash_headpp, net_hash_entry_t *entpp); @@ -1636,9 +1636,9 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) register bpf_insn_t pc, pc_end; register unsigned int buflen; - register unsigned long A, X; + register unsigned int A, X; register int k; - unsigned long mem[BPF_MEMWORDS]; + unsigned int mem[BPF_MEMWORDS]; /* Generic pointer to either HEADER or P according to the specified offset. */ char *data = NULL; @@ -1689,9 +1689,9 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) k = pc->k; load_word: - if ((u_int)k + sizeof(long) <= hlen) + if ((u_int)k + sizeof(int) <= hlen) data = header; - else if ((u_int)k + sizeof(long) <= buflen) { + else if ((u_int)k + sizeof(int) <= buflen) { k -= hlen; data = p; } else @@ -1702,7 +1702,7 @@ bpf_do_filter(infp, p, wirelen, header, hlen, hash_headpp, entpp) A = EXTRACT_LONG(&data[k]); else #endif - A = ntohl(*(long *)(data + k)); + A = ntohl(*(int *)(data + k)); continue; case BPF_LD|BPF_H|BPF_ABS: @@ -2032,7 +2032,7 @@ int bpf_match (hash, n_keys, keys, hash_headpp, entpp) net_hash_header_t hash; register int n_keys; - register unsigned long *keys; + register unsigned int *keys; net_hash_entry_t **hash_headpp, *entpp; { register net_hash_entry_t head, entp; -- cgit v1.2.3