From patchwork Sun Dec 12 20:39:12 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 614 Return-Path: Received: from v3-1039.vlinux.de (narfation.org [79.140.41.39]) by open-mesh.org (Postfix) with ESMTPS id 85B3E1545DB for ; Sun, 12 Dec 2010 21:45:44 +0100 (CET) Received: from sven-desktop.lazhur.ath.cx (unknown [88.130.164.197]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 8F5DD94025; Sun, 12 Dec 2010 21:39:27 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=narfation.org; s=mail; t=1292186368; bh=9T2Q3dC0NIMgp0AtW9Gn+6yoiBWzLwM6PtItyOcA9I8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References; b=SEiaV3dhagvS7fHBTPm+1RGJw9IQWBnFoJKcoFVG44uBFQRxkgzJ/PWFEMWAzcOHI xFMNgEwQswr3bHwD26KOQh9g+deHjtAypUV4BjzQ2ruv8o86B4++95sla4/4RRL1qG ++CTYKEsB4VAfvvHNgvyJoJtLyVZyzUSSFfXqxDo= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 12 Dec 2010 21:39:12 +0100 Message-Id: <1292186352-24624-2-git-send-email-sven@narfation.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <201012122136.48156.sven@narfation.org> References: <201012122136.48156.sven@narfation.org> Subject: [B.A.T.M.A.N.] [PATCHv2 2/2] batman-adv: Remove TYPE_OF_WORD define X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.11 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 12 Dec 2010 20:45:45 -0000 We use functions like hweight_long or set/test_bit which enforce the type "unsigned long". This makes it impossible to replace the type in this define with any other type without breaking the kernel module. Reported-by: Marek Lindner Signed-off-by: Sven Eckelmann --- batman-adv/bitarray.c | 12 ++++++------ batman-adv/bitarray.h | 13 +++++-------- batman-adv/originator.c | 8 ++++---- batman-adv/routing.c | 4 ++-- batman-adv/types.h | 6 +++--- 5 files changed, 20 insertions(+), 23 deletions(-) diff --git a/batman-adv/bitarray.c b/batman-adv/bitarray.c index 5dad5e8..bbcd8f7 100644 --- a/batman-adv/bitarray.c +++ b/batman-adv/bitarray.c @@ -26,7 +26,7 @@ /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ -uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, +uint8_t get_bit_status(unsigned long *seq_bits, uint32_t last_seqno, uint32_t curr_seqno) { int32_t diff, word_offset, word_num; @@ -48,7 +48,7 @@ uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, } /* turn corresponding bit on, so we can remember that we got the packet */ -void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) +void bit_mark(unsigned long *seq_bits, int32_t n) { int32_t word_offset, word_num; @@ -65,7 +65,7 @@ void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n) } /* shift the packet array by n places. */ -static void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) +static void bit_shift(unsigned long *seq_bits, int32_t n) { int32_t word_offset, word_num; int32_t i; @@ -113,7 +113,7 @@ static void bit_shift(TYPE_OF_WORD *seq_bits, int32_t n) seq_bits[i] = 0; } -static void bit_reset_window(TYPE_OF_WORD *seq_bits) +static void bit_reset_window(unsigned long *seq_bits) { int i; for (i = 0; i < NUM_WORDS; i++) @@ -127,7 +127,7 @@ static void bit_reset_window(TYPE_OF_WORD *seq_bits) * 1 if the window was moved (either new or very old) * 0 if the window was not moved/shifted. */ -char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, +char bit_get_packet(void *priv, unsigned long *seq_bits, int32_t seq_num_diff, int8_t set_mark) { struct bat_priv *bat_priv = (struct bat_priv *)priv; @@ -190,7 +190,7 @@ char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, /* count the hamming weight, how many good packets did we receive? just count * the 1's. */ -int bit_packet_count(TYPE_OF_WORD *seq_bits) +int bit_packet_count(unsigned long *seq_bits) { int i, hamming = 0; diff --git a/batman-adv/bitarray.h b/batman-adv/bitarray.h index 77b1e61..ac54017 100644 --- a/batman-adv/bitarray.h +++ b/batman-adv/bitarray.h @@ -22,26 +22,23 @@ #ifndef _NET_BATMAN_ADV_BITARRAY_H_ #define _NET_BATMAN_ADV_BITARRAY_H_ -/* you should choose something big, if you don't want to waste cpu - * and keep the type in sync with bit_packet_count */ -#define TYPE_OF_WORD unsigned long -#define WORD_BIT_SIZE (sizeof(TYPE_OF_WORD) * 8) +#define WORD_BIT_SIZE (sizeof(unsigned long) * 8) /* returns true if the corresponding bit in the given seq_bits indicates true * and curr_seqno is within range of last_seqno */ -uint8_t get_bit_status(TYPE_OF_WORD *seq_bits, uint32_t last_seqno, +uint8_t get_bit_status(unsigned long *seq_bits, uint32_t last_seqno, uint32_t curr_seqno); /* turn corresponding bit on, so we can remember that we got the packet */ -void bit_mark(TYPE_OF_WORD *seq_bits, int32_t n); +void bit_mark(unsigned long *seq_bits, int32_t n); /* receive and process one packet, returns 1 if received seq_num is considered * new, 0 if old */ -char bit_get_packet(void *priv, TYPE_OF_WORD *seq_bits, +char bit_get_packet(void *priv, unsigned long *seq_bits, int32_t seq_num_diff, int8_t set_mark); /* count the hamming weight, how many good packets did we receive? */ -int bit_packet_count(TYPE_OF_WORD *seq_bits); +int bit_packet_count(unsigned long *seq_bits); #endif /* _NET_BATMAN_ADV_BITARRAY_H_ */ diff --git a/batman-adv/originator.c b/batman-adv/originator.c index 89ec021..43a308e 100644 --- a/batman-adv/originator.c +++ b/batman-adv/originator.c @@ -152,7 +152,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, uint8_t *addr) orig_node->batman_seqno_reset = jiffies - 1 - msecs_to_jiffies(RESET_PROTECTION_MS); - size = bat_priv->num_ifaces * sizeof(TYPE_OF_WORD) * NUM_WORDS; + size = bat_priv->num_ifaces * sizeof(unsigned long) * NUM_WORDS; orig_node->bcast_own = kzalloc(size, GFP_ATOMIC); if (!orig_node->bcast_own) @@ -390,7 +390,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) { void *data_ptr; - data_ptr = kmalloc(max_if_num * sizeof(TYPE_OF_WORD) * NUM_WORDS, + data_ptr = kmalloc(max_if_num * sizeof(unsigned long) * NUM_WORDS, GFP_ATOMIC); if (!data_ptr) { pr_err("Can't resize orig: out of memory\n"); @@ -398,7 +398,7 @@ static int orig_node_add_if(struct orig_node *orig_node, int max_if_num) } memcpy(data_ptr, orig_node->bcast_own, - (max_if_num - 1) * sizeof(TYPE_OF_WORD) * NUM_WORDS); + (max_if_num - 1) * sizeof(unsigned long) * NUM_WORDS); kfree(orig_node->bcast_own); orig_node->bcast_own = data_ptr; @@ -453,7 +453,7 @@ static int orig_node_del_if(struct orig_node *orig_node, if (max_if_num == 0) goto free_bcast_own; - chunk_size = sizeof(TYPE_OF_WORD) * NUM_WORDS; + chunk_size = sizeof(unsigned long) * NUM_WORDS; data_ptr = kmalloc(max_if_num * chunk_size, GFP_ATOMIC); if (!data_ptr) { pr_err("Can't resize orig: out of memory\n"); diff --git a/batman-adv/routing.c b/batman-adv/routing.c index d8b0c5a..a2eba49 100644 --- a/batman-adv/routing.c +++ b/batman-adv/routing.c @@ -42,7 +42,7 @@ void slide_own_bcast_window(struct batman_if *batman_if) HASHIT(hashit); struct element_t *bucket; struct orig_node *orig_node; - TYPE_OF_WORD *word; + unsigned long *word; spin_lock_bh(&bat_priv->orig_hash_lock); @@ -626,7 +626,7 @@ void receive_bat_packet(struct ethhdr *ethhdr, } if (is_my_orig) { - TYPE_OF_WORD *word; + unsigned long *word; int offset; orig_neigh_node = get_orig_node(bat_priv, ethhdr->h_source); diff --git a/batman-adv/types.h b/batman-adv/types.h index 1d00849..97cb23d 100644 --- a/batman-adv/types.h +++ b/batman-adv/types.h @@ -68,7 +68,7 @@ struct orig_node { uint8_t orig[ETH_ALEN]; uint8_t primary_addr[ETH_ALEN]; struct neigh_node *router; - TYPE_OF_WORD *bcast_own; + unsigned long *bcast_own; uint8_t *bcast_own_sum; uint8_t tq_own; int tq_asym_penalty; @@ -81,7 +81,7 @@ struct orig_node { int16_t hna_buff_len; uint32_t last_real_seqno; uint8_t last_ttl; - TYPE_OF_WORD bcast_bits[NUM_WORDS]; + unsigned long bcast_bits[NUM_WORDS]; uint32_t last_bcast_seqno; struct list_head neigh_list; struct list_head frag_list; @@ -114,7 +114,7 @@ struct neigh_node { uint8_t last_ttl; struct neigh_node *next_bond_candidate; unsigned long last_valid; - TYPE_OF_WORD real_bits[NUM_WORDS]; + unsigned long real_bits[NUM_WORDS]; struct orig_node *orig_node; struct batman_if *if_incoming; };