Browse Source

Suppressing warning about cast in inet & list

Warning : some cast can be wrong between uintptr_t to u_int* (long unsigned
int to unsigned int)
Yann Weber 5 years ago
parent
commit
69e84711f6
12 changed files with 42 additions and 34 deletions
  1. 7
    4
      src/andna.c
  2. 2
    2
      src/andna_cache.c
  3. 3
    3
      src/andns_snsd.c
  4. 1
    0
      src/igs.c
  5. 1
    1
      src/inet.c
  6. 6
    2
      src/inet.h
  7. 1
    1
      src/llist.c
  8. 5
    5
      src/radar.c
  9. 5
    5
      src/route.c
  10. 5
    5
      src/snsd_cache.c
  11. 4
    4
      src/snsd_cache.h
  12. 2
    2
      src/tracer.c

+ 7
- 4
src/andna.c View File

@@ -955,7 +955,8 @@ andna_recv_reg_rq(PACKET rpkt)
955 955
 		 * ip and discard the rest of the snsd records
956 956
 		 */
957 957
 		snsd_add_mainip(&snsd_unpacked, &snsd_counter,
958
-						SNSD_MAX_QUEUE_RECORDS, rfrom.data);
958
+						SNSD_MAX_QUEUE_RECORDS,
959
+						(uintptr_t*)rfrom.data);
959 960
 	} else {
960 961
 		/*
961 962
 		 * Register the snsd records
@@ -992,8 +993,9 @@ andna_recv_reg_rq(PACKET rpkt)
992 993
 
993 994
 			/* Add the mainip and update its IP */
994 995
 			snd = snsd_add_mainip(&snsd_unpacked, &snsd_counter,
995
-								  SNSD_MAX_RECORDS, rfrom.data);
996
-			inet_copy_ipdata_raw(snd->record, &rfrom);
996
+								SNSD_MAX_RECORDS,
997
+								(uintptr_t*)rfrom.data);
998
+			inet_copy_ipdata_raw((u_int*)snd->record, &rfrom);
997 999
 
998 1000
 			/**
999 1001
 			 * Set the mainip flag only to the real mainip record,
@@ -1337,7 +1339,8 @@ andna_resolve_hash_locally(u_int hname_hash[MAX_IP_INT], int service,
1337 1339
 		if (service == SNSD_ALL_SERVICE ||
1338 1340
 			service == SNSD_DEFAULT_SERVICE || !ret)
1339 1341
 			snsd_add_mainip(&ret, &fake_counter,
1340
-							SNSD_MAX_RECORDS, me.cur_ip.data);
1342
+							SNSD_MAX_RECORDS,
1343
+							(uintptr_t*)me.cur_ip.data);
1341 1344
 		return ret;
1342 1345
 	}
1343 1346
 

+ 2
- 2
src/andna_cache.c View File

@@ -604,7 +604,7 @@ rh_cache_add_hash(u_int hash, time_t timestamp)
604 604
 
605 605
 			if (rhc_counter >= ANDNA_MAX_HOSTNAMES) {
606 606
 				/* Delete the oldest struct in cache */
607
-				rhc = list_last(andna_rhc);
607
+				rhc = (rh_cache *)list_last(andna_rhc);
608 608
 				clist_del(&andna_rhc, &rhc_counter, rhc);
609 609
 			}
610 610
 		}
@@ -1937,7 +1937,7 @@ load_snsd(char *file, lcl_cache * alcl_head)
1937 1937
 			 * snsd record 
1938 1938
 			 */
1939 1939
 			if (str_to_inet(records[1], &ip) >= 0) {
1940
-				inet_copy_ipdata_raw(snsd_node.record, &ip);
1940
+				inet_copy_ipdata_raw((u_int*)snsd_node.record, &ip);
1941 1941
 				snsd_node.flags = SNSD_NODE_IP;
1942 1942
 			} else {
1943 1943
 				hash_md5((u_char *) records[1], strlen(records[1]),

+ 3
- 3
src/andns_snsd.c View File

@@ -99,7 +99,7 @@ snsd_node_to_data(char *buf, snsd_node * sn, u_char prio, int iplen,
99 99
 		return iplen + 2;
100 100
 	} else if (recursion) {
101 101
 		snsd_node snt;
102
-		res = snsd_main_ip(sn->record, &snt);
102
+		res = snsd_main_ip((u_int*)sn->record, &snt);
103 103
 		if (!res) {				/* I love recursion */
104 104
 			res = snsd_node_to_data(buf, &snt, prio, iplen, -1);
105 105
 			return res;
@@ -210,7 +210,7 @@ snsd_service_to_aansws(char *buf, snsd_service * ss, int iplen, int *count,
210 210
 					inet_htonl((u_int *) buf, family);
211 211
 					buf += iplen;
212 212
 				} else {
213
-					if (recursion && !snsd_main_ip(sn->record, &snt)) {
213
+					if (recursion && !snsd_main_ip((u_int*)sn->record, &snt)) {
214 214
 						memcpy(buf, snt.record, iplen);
215 215
 						*(buf - 4) |= 0x40;
216 216
 						family = (iplen == 4) ? AF_INET : AF_INET6;
@@ -259,7 +259,7 @@ snsd_node_to_dansw(dns_pkt * dp, snsd_node * sn, int iplen)
259 259
 	int res;
260 260
 
261 261
 	if (!(sn->flags & SNSD_NODE_HNAME)) {
262
-		if (!(res = snsd_main_ip(sn->record, &snt)))
262
+		if (!(res = snsd_main_ip((u_int*)sn->record, &snt)))
263 263
 			return -1;
264 264
 		s = &snt;
265 265
 	} else

+ 1
- 0
src/igs.c View File

@@ -33,6 +33,7 @@
33 33
 #include "qspn.h"
34 34
 #include "radar.h"
35 35
 #include "andns.h"
36
+#include "andna_cache.h"
36 37
 #include "netsukuku.h"
37 38
 #include "route.h"
38 39
 #include "krnl_rule.h"

+ 1
- 1
src/inet.c View File

@@ -1200,4 +1200,4 @@ inet_sendfile64(int out_fd, int in_fd, off64_t * offset, size_t count)
1200 1200
         }
1201 1201
 	return err;
1202 1202
 }
1203
-#endif*/
1203
+#endif*/

+ 6
- 2
src/inet.h View File

@@ -74,8 +74,12 @@ typedef struct {
74 74
 	u_char family;				/* AF_INET or AF_INET6 */
75 75
 	u_short len;				/* IP length: 4 or 16 (bytes) */
76 76
 	u_char bits;				/* Number of used bits of the IP */
77
-	u_int data[MAX_IP_INT];		/* The address is kept in host long format, 
78
-								   word ORDER 1 (most significant word first) */
77
+	/* TODO : check if data should be uintptr_t instead of u_int
78
+	   note: expected ‘uintptr_t * {aka long unsigned int *}’ but argument is of type ‘u_int * {aka unsigned int *}’
79
+	   But explicit cast has been added to suppress warnings
80
+	*/
81
+	u_int data[MAX_IP_INT];			/* The address is kept in host long format, 
82
+						   word ORDER 1 (most significant word first) */
79 83
 } inet_prefix;
80 84
 
81 85
 /* int_info struct used for packing the inet_prefix struct.

+ 1
- 1
src/llist.c View File

@@ -124,7 +124,7 @@ do {									\
124 124
 ({									\
125 125
 	 l_list *_il=(l_list *)(list);					\
126 126
 	 for(; _il && _il->next; _il=(l_list *)_il->next);		\
127
- 	 (typeof((list)))_il;						\
127
+	 _il;								\
128 128
 })
129 129
 
130 130
 /*

+ 5
- 5
src/radar.c View File

@@ -118,7 +118,7 @@ free_new_node(void)
118 118
 
119 119
 	rq = radar_q;
120 120
 	list_for(rq)
121
-		if (rq->node && ((int) rq->node != RADQ_EXT_RNODE)) {
121
+		if (rq->node && ((uintptr_t) rq->node != RADQ_EXT_RNODE)) {
122 122
 		xfree(rq->node);
123 123
 		rq->node = 0;
124 124
 	}
@@ -432,7 +432,7 @@ rnl_get_sk(struct rnode_list *rnlist, map_node * node)
432 432
 			inet_copy(&to, &rq->ip);
433 433
 
434 434
 		} else {
435
-			rnodetoip((u_int) me.int_map, (u_int) node,
435
+			rnodetoip((uintptr_t) me.int_map, (uintptr_t) node,
436 436
 					  me.cur_quadg.ipstart[1], &to);
437 437
 		}
438 438
 
@@ -950,7 +950,7 @@ radar_update_map(void)
950 950
 		 * We need to know if it is a node which is not in the gnode
951 951
 		 * where we are (external_rnode).
952 952
 		 */
953
-		if ((int) rq->node == RADQ_EXT_RNODE) {
953
+		if ((uintptr_t) rq->node == RADQ_EXT_RNODE) {
954 954
 			external_node = 1;
955 955
 			total_levels = rq->quadg.levels;
956 956
 		} else {
@@ -1221,7 +1221,7 @@ add_radar_q(PACKET pkt)
1221 1221
 			  QUADG_GID | QUADG_GNODE | QUADG_IPSTART);
1222 1222
 
1223 1223
 	if (!(me.cur_node->flags & MAP_HNODE)) {
1224
-		iptomap((u_int) me.int_map, pkt.from, me.cur_quadg.ipstart[1],
1224
+		iptomap((uintptr_t) me.int_map, pkt.from, me.cur_quadg.ipstart[1],
1225 1225
 				&rnode);
1226 1226
 		ret = quadg_gids_cmp(me.cur_quadg, quadg, 1);
1227 1227
 	}
@@ -1654,7 +1654,7 @@ refresh_hook_root_node(void)
1654 1654
 
1655 1655
 	rq = radar_q;
1656 1656
 	list_for(rq) {
1657
-		ret = iptomap((u_int) me.int_map, rq->ip, me.cur_quadg.ipstart[1],
1657
+		ret = iptomap((uintptr_t) me.int_map, rq->ip, me.cur_quadg.ipstart[1],
1658 1658
 					  &rnode);
1659 1659
 		if (ret)
1660 1660
 			rq->node = (map_node *) RADQ_EXT_RNODE;

+ 5
- 5
src/route.c View File

@@ -349,7 +349,7 @@ get_gw_ips(map_node * int_map, map_gnode ** ext_map,
349 349
 			e_rnode = (ext_rnode *) gw_node[i];
350 350
 			inet_copy(&gw_ip[e], &e_rnode->quadg.ipstart[gw_level]);
351 351
 		} else
352
-			maptoip((u_int) int_map, (u_int) gw_node[i],
352
+			maptoip((uintptr_t) int_map, (uintptr_t) gw_node[i],
353 353
 					cur_quadg->ipstart[1], &gw_ip[e]);
354 354
 
355 355
 		if (gw_nodes)
@@ -405,7 +405,7 @@ rt_build_nexthop_gw(map_node * node, map_gnode * gnode, int level,
405 405
 		for (i = 0, n = 0; i < node->links; i++) {
406 406
 			tmp_node = (map_node *) node->r_node[i].r_node;
407 407
 
408
-			maptoip((u_int) me.int_map, (u_int) tmp_node,
408
+			maptoip((uintptr_t) me.int_map, (uintptr_t) tmp_node,
409 409
 					me.cur_quadg.ipstart[1], &nh[n].gw);
410 410
 			inet_htonl(nh[n].gw.data, nh[n].gw.family);
411 411
 
@@ -478,7 +478,7 @@ rt_build_nexthop_voidgw(void *void_gw, interface ** oifs)
478 478
 		e_rnode = (ext_rnode *) gw_node;
479 479
 		inet_copy(&nh[0].gw, &e_rnode->quadg.ipstart[0]);
480 480
 	} else
481
-		maptoip((u_int) me.int_map, (u_int) gw_node,
481
+		maptoip((uintptr_t) me.int_map, (uintptr_t) gw_node,
482 482
 				me.cur_quadg.ipstart[1], &nh[0].gw);
483 483
 	inet_htonl(nh[0].gw.data, nh[0].gw.family);
484 484
 	nh[0].dev = oifs[0]->dev_name;
@@ -563,8 +563,8 @@ rt_update_node(inet_prefix * dst_ip, void *dst_node,
563 563
 		gnodetoip(dst_quadg, node_pos, level, &to);
564 564
 	} else {
565 565
 		node_pos = pos_from_node(node, me.int_map);
566
-		maptoip((u_int) me.int_map, (u_int) node, me.cur_quadg.ipstart[1],
567
-				&to);
566
+		maptoip((uintptr_t) me.int_map, (uintptr_t) node,
567
+				me.cur_quadg.ipstart[1], &to);
568 568
 	}
569 569
 #ifdef DEBUG
570 570
 	to_ip = xstrdup(inet_to_str(to));

+ 5
- 5
src/snsd_cache.c View File

@@ -195,7 +195,7 @@ snsd_add_prio(snsd_prio ** head, u_char prio)
195 195
 }
196 196
 
197 197
 snsd_node *
198
-snsd_find_node_by_record(snsd_node * snd, u_int record[MAX_IP_INT])
198
+snsd_find_node_by_record(snsd_node * snd, uintptr_t record[MAX_IP_INT])
199 199
 {
200 200
 	list_for(snd)
201 201
 		if (!memcmp(snd->record, record, MAX_IP_SZ))
@@ -216,7 +216,7 @@ snsd_find_node_by_record(snsd_node * snd, u_int record[MAX_IP_INT])
216 216
  */
217 217
 snsd_node *
218 218
 snsd_add_node(snsd_node ** head, u_short * counter,
219
-			  u_short max_records, u_int record[MAX_IP_INT])
219
+			  u_short max_records, uintptr_t record[MAX_IP_INT])
220 220
 {
221 221
 	snsd_node *snd;
222 222
 
@@ -246,7 +246,7 @@ snsd_add_node(snsd_node ** head, u_short * counter,
246 246
  */
247 247
 snsd_node *
248 248
 snsd_add_first_node(snsd_node ** head, u_short * counter,
249
-					u_short max_records, u_int record[MAX_IP_INT])
249
+					u_short max_records, uintptr_t record[MAX_IP_INT])
250 250
 {
251 251
 	if (!(*head) || !(*counter))
252 252
 		return snsd_add_node(head, counter, max_records, record);
@@ -259,7 +259,7 @@ snsd_add_first_node(snsd_node ** head, u_short * counter,
259 259
  */
260 260
 snsd_node *
261 261
 snsd_add_mainip(snsd_service ** head, u_short * counter,
262
-				u_short max_records, u_int record[MAX_IP_INT])
262
+				u_short max_records, uintptr_t record[MAX_IP_INT])
263 263
 {
264 264
 	snsd_service *sns;
265 265
 	snsd_prio *snp;
@@ -431,7 +431,7 @@ snsd_unpack_node(char *pack)
431 431
 	buf += sizeof(char);
432 432
 
433 433
 	if (snd->flags & SNSD_NODE_IP)
434
-		inet_ntohl(snd->record, net_family);
434
+		inet_ntohl((u_int*)snd->record, net_family);
435 435
 
436 436
 	return snd;
437 437
 }

+ 4
- 4
src/snsd_cache.h View File

@@ -97,7 +97,7 @@
97 97
 struct snsd_node {
98 98
 	LLIST_HDR(struct snsd_node);
99 99
 
100
-	u_int record[MAX_IP_INT];	/* It can be the IP or the md5
100
+	uintptr_t record[MAX_IP_INT];	/* It can be the IP or the md5
101 101
 								   hash of the hname of the 
102 102
 								   SNSD node */
103 103
 	RSA *pubkey;				/* pubkey of the snsd_node */
@@ -267,11 +267,11 @@ snsd_service *snsd_add_service(snsd_service ** head, u_short service,
267 267
 snsd_prio *snsd_find_prio(snsd_prio * snp, u_char prio);
268 268
 snsd_prio *snsd_add_prio(snsd_prio ** head, u_char prio);
269 269
 snsd_node *snsd_find_node_by_record(snsd_node * snd,
270
-									u_int record[MAX_IP_INT]);
270
+									uintptr_t record[MAX_IP_INT]);
271 271
 snsd_node *snsd_add_node(snsd_node ** head, u_short * counter,
272
-						 u_short max_records, u_int record[MAX_IP_INT]);
272
+						 u_short max_records, uintptr_t record[MAX_IP_INT]);
273 273
 snsd_node *snsd_add_mainip(snsd_service ** head, u_short * counter,
274
-						   u_short max_records, u_int record[MAX_IP_INT]);
274
+						   u_short max_records, uintptr_t record[MAX_IP_INT]);
275 275
 void snsd_service_llist_del(snsd_service ** head);
276 276
 void snsd_record_del_selected(snsd_service ** head, u_short * snd_counter,
277 277
 							  snsd_service * selected);

+ 2
- 2
src/tracer.c View File

@@ -67,7 +67,7 @@ ip_to_rfrom(inet_prefix rip, quadro_group * rip_quadg,
67 67
 		external_node = 1;
68 68
 
69 69
 	if (!external_node) {
70
-		iptomap((u_int) me.int_map, rip, me.cur_quadg.ipstart[1], &from);
70
+		iptomap((uintptr_t) me.int_map, rip, me.cur_quadg.ipstart[1], &from);
71 71
 		ret = rnode_find(me.cur_node, from);
72 72
 	} else {
73 73
 		erc = e_rnode_find(me.cur_erc, quadg, 0);
@@ -116,7 +116,7 @@ tracer_verify_pkt(tracer_chunk * tracer, u_short hops, inet_prefix rip,
116 116
 	 */
117 117
 
118 118
 	if (!level) {
119
-		iptomap((u_int) me.int_map, rip, me.cur_quadg.ipstart[1],
119
+		iptomap((uintptr_t) me.int_map, rip, me.cur_quadg.ipstart[1],
120 120
 				&real_from);
121 121
 		from = node_from_pos(tracer[hops - 1].node, me.int_map);
122 122
 	} else {

Loading…
Cancel
Save