aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/vis.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2011-05-14 17:14:50 -0400
committerSven Eckelmann <sven@narfation.org>2011-05-30 01:39:31 -0400
commit747e4221a03cde62402b614ca1f8e961b8416130 (patch)
tree98428064fef191a5093e276d5a779b9e801a97f0 /net/batman-adv/vis.c
parent38e3c5f0dae7a3bbb32c3b2bb28c3f2557d40fe9 (diff)
batman-adv: Add const type qualifier for pointers
batman-adv uses pointers which are marked as const and should not violate that type qualifier by passing it to functions which force a cast to the non-const version. Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net/batman-adv/vis.c')
-rw-r--r--net/batman-adv/vis.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c
index c39f20cc1ba6..adb0327ff28b 100644
--- a/net/batman-adv/vis.c
+++ b/net/batman-adv/vis.c
@@ -68,10 +68,10 @@ static void free_info(struct kref *ref)
68} 68}
69 69
70/* Compare two vis packets, used by the hashing algorithm */ 70/* Compare two vis packets, used by the hashing algorithm */
71static int vis_info_cmp(struct hlist_node *node, void *data2) 71static int vis_info_cmp(const struct hlist_node *node, const void *data2)
72{ 72{
73 struct vis_info *d1, *d2; 73 const struct vis_info *d1, *d2;
74 struct vis_packet *p1, *p2; 74 const struct vis_packet *p1, *p2;
75 75
76 d1 = container_of(node, struct vis_info, hash_entry); 76 d1 = container_of(node, struct vis_info, hash_entry);
77 d2 = data2; 77 d2 = data2;
@@ -82,11 +82,11 @@ static int vis_info_cmp(struct hlist_node *node, void *data2)
82 82
83/* hash function to choose an entry in a hash table of given size */ 83/* hash function to choose an entry in a hash table of given size */
84/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */ 84/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
85static int vis_info_choose(void *data, int size) 85static int vis_info_choose(const void *data, int size)
86{ 86{
87 struct vis_info *vis_info = data; 87 const struct vis_info *vis_info = data;
88 struct vis_packet *packet; 88 const struct vis_packet *packet;
89 unsigned char *key; 89 const unsigned char *key;
90 uint32_t hash = 0; 90 uint32_t hash = 0;
91 size_t i; 91 size_t i;
92 92
@@ -106,7 +106,7 @@ static int vis_info_choose(void *data, int size)
106} 106}
107 107
108static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, 108static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
109 void *data) 109 const void *data)
110{ 110{
111 struct hashtable_t *hash = bat_priv->vis_hash; 111 struct hashtable_t *hash = bat_priv->vis_hash;
112 struct hlist_head *head; 112 struct hlist_head *head;
@@ -143,7 +143,7 @@ static void vis_data_insert_interface(const uint8_t *interface,
143 struct hlist_node *pos; 143 struct hlist_node *pos;
144 144
145 hlist_for_each_entry(entry, pos, if_list, list) { 145 hlist_for_each_entry(entry, pos, if_list, list) {
146 if (compare_eth(entry->addr, (void *)interface)) 146 if (compare_eth(entry->addr, interface))
147 return; 147 return;
148 } 148 }
149 149
@@ -156,7 +156,8 @@ static void vis_data_insert_interface(const uint8_t *interface,
156 hlist_add_head(&entry->list, if_list); 156 hlist_add_head(&entry->list, if_list);
157} 157}
158 158
159static ssize_t vis_data_read_prim_sec(char *buff, struct hlist_head *if_list) 159static ssize_t vis_data_read_prim_sec(char *buff,
160 const struct hlist_head *if_list)
160{ 161{
161 struct if_list_entry *entry; 162 struct if_list_entry *entry;
162 struct hlist_node *pos; 163 struct hlist_node *pos;
@@ -189,8 +190,9 @@ static size_t vis_data_count_prim_sec(struct hlist_head *if_list)
189} 190}
190 191
191/* read an entry */ 192/* read an entry */
192static ssize_t vis_data_read_entry(char *buff, struct vis_info_entry *entry, 193static ssize_t vis_data_read_entry(char *buff,
193 uint8_t *src, bool primary) 194 const struct vis_info_entry *entry,
195 const uint8_t *src, bool primary)
194{ 196{
195 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ 197 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
196 if (primary && entry->quality == 0) 198 if (primary && entry->quality == 0)
@@ -361,7 +363,7 @@ static void send_list_del(struct vis_info *info)
361 363
362/* tries to add one entry to the receive list. */ 364/* tries to add one entry to the receive list. */
363static void recv_list_add(struct bat_priv *bat_priv, 365static void recv_list_add(struct bat_priv *bat_priv,
364 struct list_head *recv_list, char *mac) 366 struct list_head *recv_list, const char *mac)
365{ 367{
366 struct recvlist_node *entry; 368 struct recvlist_node *entry;
367 369
@@ -377,9 +379,9 @@ static void recv_list_add(struct bat_priv *bat_priv,
377 379
378/* returns 1 if this mac is in the recv_list */ 380/* returns 1 if this mac is in the recv_list */
379static int recv_list_is_in(struct bat_priv *bat_priv, 381static int recv_list_is_in(struct bat_priv *bat_priv,
380 struct list_head *recv_list, char *mac) 382 const struct list_head *recv_list, const char *mac)
381{ 383{
382 struct recvlist_node *entry; 384 const struct recvlist_node *entry;
383 385
384 spin_lock_bh(&bat_priv->vis_list_lock); 386 spin_lock_bh(&bat_priv->vis_list_lock);
385 list_for_each_entry(entry, recv_list, list) { 387 list_for_each_entry(entry, recv_list, list) {
@@ -599,9 +601,9 @@ static int find_best_vis_server(struct bat_priv *bat_priv,
599} 601}
600 602
601/* Return true if the vis packet is full. */ 603/* Return true if the vis packet is full. */
602static bool vis_packet_full(struct vis_info *info) 604static bool vis_packet_full(const struct vis_info *info)
603{ 605{
604 struct vis_packet *packet; 606 const struct vis_packet *packet;
605 packet = (struct vis_packet *)info->skb_packet->data; 607 packet = (struct vis_packet *)info->skb_packet->data;
606 608
607 if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry) 609 if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry)