瀏覽代碼

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 年之前
父節點
當前提交
69e84711f6
共有 12 個文件被更改,包括 42 次插入34 次删除
  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 查看文件

955
 		 * ip and discard the rest of the snsd records
955
 		 * ip and discard the rest of the snsd records
956
 		 */
956
 		 */
957
 		snsd_add_mainip(&snsd_unpacked, &snsd_counter,
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
 	} else {
960
 	} else {
960
 		/*
961
 		/*
961
 		 * Register the snsd records
962
 		 * Register the snsd records
992
 
993
 
993
 			/* Add the mainip and update its IP */
994
 			/* Add the mainip and update its IP */
994
 			snd = snsd_add_mainip(&snsd_unpacked, &snsd_counter,
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
 			 * Set the mainip flag only to the real mainip record,
1001
 			 * Set the mainip flag only to the real mainip record,
1337
 		if (service == SNSD_ALL_SERVICE ||
1339
 		if (service == SNSD_ALL_SERVICE ||
1338
 			service == SNSD_DEFAULT_SERVICE || !ret)
1340
 			service == SNSD_DEFAULT_SERVICE || !ret)
1339
 			snsd_add_mainip(&ret, &fake_counter,
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
 		return ret;
1344
 		return ret;
1342
 	}
1345
 	}
1343
 
1346
 

+ 2
- 2
src/andna_cache.c 查看文件

604
 
604
 
605
 			if (rhc_counter >= ANDNA_MAX_HOSTNAMES) {
605
 			if (rhc_counter >= ANDNA_MAX_HOSTNAMES) {
606
 				/* Delete the oldest struct in cache */
606
 				/* Delete the oldest struct in cache */
607
-				rhc = list_last(andna_rhc);
607
+				rhc = (rh_cache *)list_last(andna_rhc);
608
 				clist_del(&andna_rhc, &rhc_counter, rhc);
608
 				clist_del(&andna_rhc, &rhc_counter, rhc);
609
 			}
609
 			}
610
 		}
610
 		}
1937
 			 * snsd record 
1937
 			 * snsd record 
1938
 			 */
1938
 			 */
1939
 			if (str_to_inet(records[1], &ip) >= 0) {
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
 				snsd_node.flags = SNSD_NODE_IP;
1941
 				snsd_node.flags = SNSD_NODE_IP;
1942
 			} else {
1942
 			} else {
1943
 				hash_md5((u_char *) records[1], strlen(records[1]),
1943
 				hash_md5((u_char *) records[1], strlen(records[1]),

+ 3
- 3
src/andns_snsd.c 查看文件

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

+ 1
- 0
src/igs.c 查看文件

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

+ 1
- 1
src/inet.c 查看文件

1200
         }
1200
         }
1201
 	return err;
1201
 	return err;
1202
 }
1202
 }
1203
-#endif*/
1203
+#endif*/

+ 6
- 2
src/inet.h 查看文件

74
 	u_char family;				/* AF_INET or AF_INET6 */
74
 	u_char family;				/* AF_INET or AF_INET6 */
75
 	u_short len;				/* IP length: 4 or 16 (bytes) */
75
 	u_short len;				/* IP length: 4 or 16 (bytes) */
76
 	u_char bits;				/* Number of used bits of the IP */
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
 } inet_prefix;
83
 } inet_prefix;
80
 
84
 
81
 /* int_info struct used for packing the inet_prefix struct.
85
 /* int_info struct used for packing the inet_prefix struct.

+ 1
- 1
src/llist.c 查看文件

124
 ({									\
124
 ({									\
125
 	 l_list *_il=(l_list *)(list);					\
125
 	 l_list *_il=(l_list *)(list);					\
126
 	 for(; _il && _il->next; _il=(l_list *)_il->next);		\
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 查看文件

118
 
118
 
119
 	rq = radar_q;
119
 	rq = radar_q;
120
 	list_for(rq)
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
 		xfree(rq->node);
122
 		xfree(rq->node);
123
 		rq->node = 0;
123
 		rq->node = 0;
124
 	}
124
 	}
432
 			inet_copy(&to, &rq->ip);
432
 			inet_copy(&to, &rq->ip);
433
 
433
 
434
 		} else {
434
 		} else {
435
-			rnodetoip((u_int) me.int_map, (u_int) node,
435
+			rnodetoip((uintptr_t) me.int_map, (uintptr_t) node,
436
 					  me.cur_quadg.ipstart[1], &to);
436
 					  me.cur_quadg.ipstart[1], &to);
437
 		}
437
 		}
438
 
438
 
950
 		 * We need to know if it is a node which is not in the gnode
950
 		 * We need to know if it is a node which is not in the gnode
951
 		 * where we are (external_rnode).
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
 			external_node = 1;
954
 			external_node = 1;
955
 			total_levels = rq->quadg.levels;
955
 			total_levels = rq->quadg.levels;
956
 		} else {
956
 		} else {
1221
 			  QUADG_GID | QUADG_GNODE | QUADG_IPSTART);
1221
 			  QUADG_GID | QUADG_GNODE | QUADG_IPSTART);
1222
 
1222
 
1223
 	if (!(me.cur_node->flags & MAP_HNODE)) {
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
 				&rnode);
1225
 				&rnode);
1226
 		ret = quadg_gids_cmp(me.cur_quadg, quadg, 1);
1226
 		ret = quadg_gids_cmp(me.cur_quadg, quadg, 1);
1227
 	}
1227
 	}
1654
 
1654
 
1655
 	rq = radar_q;
1655
 	rq = radar_q;
1656
 	list_for(rq) {
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
 					  &rnode);
1658
 					  &rnode);
1659
 		if (ret)
1659
 		if (ret)
1660
 			rq->node = (map_node *) RADQ_EXT_RNODE;
1660
 			rq->node = (map_node *) RADQ_EXT_RNODE;

+ 5
- 5
src/route.c 查看文件

349
 			e_rnode = (ext_rnode *) gw_node[i];
349
 			e_rnode = (ext_rnode *) gw_node[i];
350
 			inet_copy(&gw_ip[e], &e_rnode->quadg.ipstart[gw_level]);
350
 			inet_copy(&gw_ip[e], &e_rnode->quadg.ipstart[gw_level]);
351
 		} else
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
 					cur_quadg->ipstart[1], &gw_ip[e]);
353
 					cur_quadg->ipstart[1], &gw_ip[e]);
354
 
354
 
355
 		if (gw_nodes)
355
 		if (gw_nodes)
405
 		for (i = 0, n = 0; i < node->links; i++) {
405
 		for (i = 0, n = 0; i < node->links; i++) {
406
 			tmp_node = (map_node *) node->r_node[i].r_node;
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
 					me.cur_quadg.ipstart[1], &nh[n].gw);
409
 					me.cur_quadg.ipstart[1], &nh[n].gw);
410
 			inet_htonl(nh[n].gw.data, nh[n].gw.family);
410
 			inet_htonl(nh[n].gw.data, nh[n].gw.family);
411
 
411
 
478
 		e_rnode = (ext_rnode *) gw_node;
478
 		e_rnode = (ext_rnode *) gw_node;
479
 		inet_copy(&nh[0].gw, &e_rnode->quadg.ipstart[0]);
479
 		inet_copy(&nh[0].gw, &e_rnode->quadg.ipstart[0]);
480
 	} else
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
 				me.cur_quadg.ipstart[1], &nh[0].gw);
482
 				me.cur_quadg.ipstart[1], &nh[0].gw);
483
 	inet_htonl(nh[0].gw.data, nh[0].gw.family);
483
 	inet_htonl(nh[0].gw.data, nh[0].gw.family);
484
 	nh[0].dev = oifs[0]->dev_name;
484
 	nh[0].dev = oifs[0]->dev_name;
563
 		gnodetoip(dst_quadg, node_pos, level, &to);
563
 		gnodetoip(dst_quadg, node_pos, level, &to);
564
 	} else {
564
 	} else {
565
 		node_pos = pos_from_node(node, me.int_map);
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
 #ifdef DEBUG
569
 #ifdef DEBUG
570
 	to_ip = xstrdup(inet_to_str(to));
570
 	to_ip = xstrdup(inet_to_str(to));

+ 5
- 5
src/snsd_cache.c 查看文件

195
 }
195
 }
196
 
196
 
197
 snsd_node *
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
 	list_for(snd)
200
 	list_for(snd)
201
 		if (!memcmp(snd->record, record, MAX_IP_SZ))
201
 		if (!memcmp(snd->record, record, MAX_IP_SZ))
216
  */
216
  */
217
 snsd_node *
217
 snsd_node *
218
 snsd_add_node(snsd_node ** head, u_short * counter,
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
 	snsd_node *snd;
221
 	snsd_node *snd;
222
 
222
 
246
  */
246
  */
247
 snsd_node *
247
 snsd_node *
248
 snsd_add_first_node(snsd_node ** head, u_short * counter,
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
 	if (!(*head) || !(*counter))
251
 	if (!(*head) || !(*counter))
252
 		return snsd_add_node(head, counter, max_records, record);
252
 		return snsd_add_node(head, counter, max_records, record);
259
  */
259
  */
260
 snsd_node *
260
 snsd_node *
261
 snsd_add_mainip(snsd_service ** head, u_short * counter,
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
 	snsd_service *sns;
264
 	snsd_service *sns;
265
 	snsd_prio *snp;
265
 	snsd_prio *snp;
431
 	buf += sizeof(char);
431
 	buf += sizeof(char);
432
 
432
 
433
 	if (snd->flags & SNSD_NODE_IP)
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
 	return snd;
436
 	return snd;
437
 }
437
 }

+ 4
- 4
src/snsd_cache.h 查看文件

97
 struct snsd_node {
97
 struct snsd_node {
98
 	LLIST_HDR(struct snsd_node);
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
 								   hash of the hname of the 
101
 								   hash of the hname of the 
102
 								   SNSD node */
102
 								   SNSD node */
103
 	RSA *pubkey;				/* pubkey of the snsd_node */
103
 	RSA *pubkey;				/* pubkey of the snsd_node */
267
 snsd_prio *snsd_find_prio(snsd_prio * snp, u_char prio);
267
 snsd_prio *snsd_find_prio(snsd_prio * snp, u_char prio);
268
 snsd_prio *snsd_add_prio(snsd_prio ** head, u_char prio);
268
 snsd_prio *snsd_add_prio(snsd_prio ** head, u_char prio);
269
 snsd_node *snsd_find_node_by_record(snsd_node * snd,
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
 snsd_node *snsd_add_node(snsd_node ** head, u_short * counter,
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
 snsd_node *snsd_add_mainip(snsd_service ** head, u_short * counter,
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
 void snsd_service_llist_del(snsd_service ** head);
275
 void snsd_service_llist_del(snsd_service ** head);
276
 void snsd_record_del_selected(snsd_service ** head, u_short * snd_counter,
276
 void snsd_record_del_selected(snsd_service ** head, u_short * snd_counter,
277
 							  snsd_service * selected);
277
 							  snsd_service * selected);

+ 2
- 2
src/tracer.c 查看文件

67
 		external_node = 1;
67
 		external_node = 1;
68
 
68
 
69
 	if (!external_node) {
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
 		ret = rnode_find(me.cur_node, from);
71
 		ret = rnode_find(me.cur_node, from);
72
 	} else {
72
 	} else {
73
 		erc = e_rnode_find(me.cur_erc, quadg, 0);
73
 		erc = e_rnode_find(me.cur_erc, quadg, 0);
116
 	 */
116
 	 */
117
 
117
 
118
 	if (!level) {
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
 				&real_from);
120
 				&real_from);
121
 		from = node_from_pos(tracer[hops - 1].node, me.int_map);
121
 		from = node_from_pos(tracer[hops - 1].node, me.int_map);
122
 	} else {
122
 	} else {

Loading…
取消
儲存