aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/vis.c
diff options
context:
space:
mode:
authorAntonio Quartulli <ordex@autistici.org>2011-10-05 11:05:25 -0400
committerSven Eckelmann <sven@narfation.org>2011-11-20 07:08:33 -0500
commitc90681b8505946761b55d4981c9c3b56b3c4171b (patch)
treeb260388317b5dc1f4a8c00493eea6ff30fb47652 /net/batman-adv/vis.c
parenteb7e2a1e20488f91c7007caa080b83b8e4222572 (diff)
batman-adv: fixed hash functions type to uint32_t instead of int
There are two reasons for this fix: - the result of choose_orig() and vis_choose() is an index and therefore it can't be negative. Hence it is correct to make the return type unsigned too. - sizeof(int) may not be the same on ALL the architectures. Since we plan to use choose_orig() as DHT hash function, we need to guarantee that, given the same argument, the result is the same. Then it is correct to explicitly express the size of the return type (and the second argument). Since the expected length is currently 4, uint32_t is the most convenient choice. Signed-off-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r--net/batman-adv/vis.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index f81a6b668b0c..7445413253ca 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -66,7 +66,7 @@ static int vis_info_cmp(const struct hlist_node *node, const void *data2)
66 66
67/* hash function to choose an entry in a hash table of given size */ 67/* hash function to choose an entry in a hash table of given size */
68/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ 68/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
69static int vis_info_choose(const void *data, int size) 69static uint32_t vis_info_choose(const void *data, uint32_t size)
70{ 70{
71 const struct vis_info *vis_info = data; 71 const struct vis_info *vis_info = data;
72 const struct vis_packet *packet; 72 const struct vis_packet *packet;
@@ -96,7 +96,7 @@ static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
96 struct hlist_head *head; 96 struct hlist_head *head;
97 struct hlist_node *node; 97 struct hlist_node *node;
98 struct vis_info *vis_info, *vis_info_tmp = NULL; 98 struct vis_info *vis_info, *vis_info_tmp = NULL;
99 int index; 99 uint32_t index;
100 100
101 if (!hash) 101 if (!hash)
102 return NULL; 102 return NULL;
@@ -202,7 +202,8 @@ int vis_seq_print_text(struct seq_file *seq, void *offset)
202 HLIST_HEAD(vis_if_list); 202 HLIST_HEAD(vis_if_list);
203 struct if_list_entry *entry; 203 struct if_list_entry *entry;
204 struct hlist_node *pos, *n; 204 struct hlist_node *pos, *n;
205 int i, j, ret = 0; 205 uint32_t i;
206 int j, ret = 0;
206 int vis_server = atomic_read(&bat_priv->vis_mode); 207 int vis_server = atomic_read(&bat_priv->vis_mode);
207 size_t buff_pos, buf_size; 208 size_t buff_pos, buf_size;
208 char *buff; 209 char *buff;
@@ -556,7 +557,8 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
556 struct hlist_head *head; 557 struct hlist_head *head;
557 struct orig_node *orig_node; 558 struct orig_node *orig_node;
558 struct vis_packet *packet; 559 struct vis_packet *packet;
559 int best_tq = -1, i; 560 int best_tq = -1;
561 uint32_t i;
560 562
561 packet = (struct vis_packet *)info->skb_packet->data; 563 packet = (struct vis_packet *)info->skb_packet->data;
562 564
@@ -608,7 +610,8 @@ static int generate_vis_packet(struct bat_priv *bat_priv)
608 struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; 610 struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data;
609 struct vis_info_entry *entry; 611 struct vis_info_entry *entry;
610 struct tt_local_entry *tt_local_entry; 612 struct tt_local_entry *tt_local_entry;
611 int best_tq = -1, i; 613 int best_tq = -1;
614 uint32_t i;
612 615
613 info->first_seen = jiffies; 616 info->first_seen = jiffies;
614 packet->vis_type = atomic_read(&bat_priv->vis_mode); 617 packet->vis_type = atomic_read(&bat_priv->vis_mode);
@@ -696,7 +699,7 @@ unlock:
696 * held */ 699 * held */
697static void purge_vis_packets(struct bat_priv *bat_priv) 700static void purge_vis_packets(struct bat_priv *bat_priv)
698{ 701{
699 int i; 702 uint32_t i;
700 struct hashtable_t *hash = bat_priv->vis_hash; 703 struct hashtable_t *hash = bat_priv->vis_hash;
701 struct hlist_node *node, *node_tmp; 704 struct hlist_node *node, *node_tmp;
702 struct hlist_head *head; 705 struct hlist_head *head;
@@ -733,7 +736,7 @@ static void broadcast_vis_packet(struct bat_priv *bat_priv,
733 struct sk_buff *skb; 736 struct sk_buff *skb;
734 struct hard_iface *hard_iface; 737 struct hard_iface *hard_iface;
735 uint8_t dstaddr[ETH_ALEN]; 738 uint8_t dstaddr[ETH_ALEN];
736 int i; 739 uint32_t i;
737 740
738 741
739 packet = (struct vis_packet *)info->skb_packet->data; 742 packet = (struct vis_packet *)info->skb_packet->data;