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)
This commit is contained in:
Yann Weber 2018-06-29 13:42:36 +02:00
commit 69e84711f6
12 changed files with 42 additions and 34 deletions

View file

@ -955,7 +955,8 @@ andna_recv_reg_rq(PACKET rpkt)
* ip and discard the rest of the snsd records
*/
snsd_add_mainip(&snsd_unpacked, &snsd_counter,
SNSD_MAX_QUEUE_RECORDS, rfrom.data);
SNSD_MAX_QUEUE_RECORDS,
(uintptr_t*)rfrom.data);
} else {
/*
* Register the snsd records
@ -992,8 +993,9 @@ andna_recv_reg_rq(PACKET rpkt)
/* Add the mainip and update its IP */
snd = snsd_add_mainip(&snsd_unpacked, &snsd_counter,
SNSD_MAX_RECORDS, rfrom.data);
inet_copy_ipdata_raw(snd->record, &rfrom);
SNSD_MAX_RECORDS,
(uintptr_t*)rfrom.data);
inet_copy_ipdata_raw((u_int*)snd->record, &rfrom);
/**
* 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,
if (service == SNSD_ALL_SERVICE ||
service == SNSD_DEFAULT_SERVICE || !ret)
snsd_add_mainip(&ret, &fake_counter,
SNSD_MAX_RECORDS, me.cur_ip.data);
SNSD_MAX_RECORDS,
(uintptr_t*)me.cur_ip.data);
return ret;
}

View file

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

View file

@ -99,7 +99,7 @@ snsd_node_to_data(char *buf, snsd_node * sn, u_char prio, int iplen,
return iplen + 2;
} else if (recursion) {
snsd_node snt;
res = snsd_main_ip(sn->record, &snt);
res = snsd_main_ip((u_int*)sn->record, &snt);
if (!res) { /* I love recursion */
res = snsd_node_to_data(buf, &snt, prio, iplen, -1);
return res;
@ -210,7 +210,7 @@ snsd_service_to_aansws(char *buf, snsd_service * ss, int iplen, int *count,
inet_htonl((u_int *) buf, family);
buf += iplen;
} else {
if (recursion && !snsd_main_ip(sn->record, &snt)) {
if (recursion && !snsd_main_ip((u_int*)sn->record, &snt)) {
memcpy(buf, snt.record, iplen);
*(buf - 4) |= 0x40;
family = (iplen == 4) ? AF_INET : AF_INET6;
@ -259,7 +259,7 @@ snsd_node_to_dansw(dns_pkt * dp, snsd_node * sn, int iplen)
int res;
if (!(sn->flags & SNSD_NODE_HNAME)) {
if (!(res = snsd_main_ip(sn->record, &snt)))
if (!(res = snsd_main_ip((u_int*)sn->record, &snt)))
return -1;
s = &snt;
} else

View file

@ -33,6 +33,7 @@
#include "qspn.h"
#include "radar.h"
#include "andns.h"
#include "andna_cache.h"
#include "netsukuku.h"
#include "route.h"
#include "krnl_rule.h"

View file

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

View file

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

View file

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

View file

@ -118,7 +118,7 @@ free_new_node(void)
rq = radar_q;
list_for(rq)
if (rq->node && ((int) rq->node != RADQ_EXT_RNODE)) {
if (rq->node && ((uintptr_t) rq->node != RADQ_EXT_RNODE)) {
xfree(rq->node);
rq->node = 0;
}
@ -432,7 +432,7 @@ rnl_get_sk(struct rnode_list *rnlist, map_node * node)
inet_copy(&to, &rq->ip);
} else {
rnodetoip((u_int) me.int_map, (u_int) node,
rnodetoip((uintptr_t) me.int_map, (uintptr_t) node,
me.cur_quadg.ipstart[1], &to);
}
@ -950,7 +950,7 @@ radar_update_map(void)
* We need to know if it is a node which is not in the gnode
* where we are (external_rnode).
*/
if ((int) rq->node == RADQ_EXT_RNODE) {
if ((uintptr_t) rq->node == RADQ_EXT_RNODE) {
external_node = 1;
total_levels = rq->quadg.levels;
} else {
@ -1221,7 +1221,7 @@ add_radar_q(PACKET pkt)
QUADG_GID | QUADG_GNODE | QUADG_IPSTART);
if (!(me.cur_node->flags & MAP_HNODE)) {
iptomap((u_int) me.int_map, pkt.from, me.cur_quadg.ipstart[1],
iptomap((uintptr_t) me.int_map, pkt.from, me.cur_quadg.ipstart[1],
&rnode);
ret = quadg_gids_cmp(me.cur_quadg, quadg, 1);
}
@ -1654,7 +1654,7 @@ refresh_hook_root_node(void)
rq = radar_q;
list_for(rq) {
ret = iptomap((u_int) me.int_map, rq->ip, me.cur_quadg.ipstart[1],
ret = iptomap((uintptr_t) me.int_map, rq->ip, me.cur_quadg.ipstart[1],
&rnode);
if (ret)
rq->node = (map_node *) RADQ_EXT_RNODE;

View file

@ -349,7 +349,7 @@ get_gw_ips(map_node * int_map, map_gnode ** ext_map,
e_rnode = (ext_rnode *) gw_node[i];
inet_copy(&gw_ip[e], &e_rnode->quadg.ipstart[gw_level]);
} else
maptoip((u_int) int_map, (u_int) gw_node[i],
maptoip((uintptr_t) int_map, (uintptr_t) gw_node[i],
cur_quadg->ipstart[1], &gw_ip[e]);
if (gw_nodes)
@ -405,7 +405,7 @@ rt_build_nexthop_gw(map_node * node, map_gnode * gnode, int level,
for (i = 0, n = 0; i < node->links; i++) {
tmp_node = (map_node *) node->r_node[i].r_node;
maptoip((u_int) me.int_map, (u_int) tmp_node,
maptoip((uintptr_t) me.int_map, (uintptr_t) tmp_node,
me.cur_quadg.ipstart[1], &nh[n].gw);
inet_htonl(nh[n].gw.data, nh[n].gw.family);
@ -478,7 +478,7 @@ rt_build_nexthop_voidgw(void *void_gw, interface ** oifs)
e_rnode = (ext_rnode *) gw_node;
inet_copy(&nh[0].gw, &e_rnode->quadg.ipstart[0]);
} else
maptoip((u_int) me.int_map, (u_int) gw_node,
maptoip((uintptr_t) me.int_map, (uintptr_t) gw_node,
me.cur_quadg.ipstart[1], &nh[0].gw);
inet_htonl(nh[0].gw.data, nh[0].gw.family);
nh[0].dev = oifs[0]->dev_name;
@ -563,8 +563,8 @@ rt_update_node(inet_prefix * dst_ip, void *dst_node,
gnodetoip(dst_quadg, node_pos, level, &to);
} else {
node_pos = pos_from_node(node, me.int_map);
maptoip((u_int) me.int_map, (u_int) node, me.cur_quadg.ipstart[1],
&to);
maptoip((uintptr_t) me.int_map, (uintptr_t) node,
me.cur_quadg.ipstart[1], &to);
}
#ifdef DEBUG
to_ip = xstrdup(inet_to_str(to));

View file

@ -195,7 +195,7 @@ snsd_add_prio(snsd_prio ** head, u_char prio)
}
snsd_node *
snsd_find_node_by_record(snsd_node * snd, u_int record[MAX_IP_INT])
snsd_find_node_by_record(snsd_node * snd, uintptr_t record[MAX_IP_INT])
{
list_for(snd)
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])
*/
snsd_node *
snsd_add_node(snsd_node ** head, u_short * counter,
u_short max_records, u_int record[MAX_IP_INT])
u_short max_records, uintptr_t record[MAX_IP_INT])
{
snsd_node *snd;
@ -246,7 +246,7 @@ snsd_add_node(snsd_node ** head, u_short * counter,
*/
snsd_node *
snsd_add_first_node(snsd_node ** head, u_short * counter,
u_short max_records, u_int record[MAX_IP_INT])
u_short max_records, uintptr_t record[MAX_IP_INT])
{
if (!(*head) || !(*counter))
return snsd_add_node(head, counter, max_records, record);
@ -259,7 +259,7 @@ snsd_add_first_node(snsd_node ** head, u_short * counter,
*/
snsd_node *
snsd_add_mainip(snsd_service ** head, u_short * counter,
u_short max_records, u_int record[MAX_IP_INT])
u_short max_records, uintptr_t record[MAX_IP_INT])
{
snsd_service *sns;
snsd_prio *snp;
@ -431,7 +431,7 @@ snsd_unpack_node(char *pack)
buf += sizeof(char);
if (snd->flags & SNSD_NODE_IP)
inet_ntohl(snd->record, net_family);
inet_ntohl((u_int*)snd->record, net_family);
return snd;
}

View file

@ -97,7 +97,7 @@
struct snsd_node {
LLIST_HDR(struct snsd_node);
u_int record[MAX_IP_INT]; /* It can be the IP or the md5
uintptr_t record[MAX_IP_INT]; /* It can be the IP or the md5
hash of the hname of the
SNSD node */
RSA *pubkey; /* pubkey of the snsd_node */
@ -267,11 +267,11 @@ snsd_service *snsd_add_service(snsd_service ** head, u_short service,
snsd_prio *snsd_find_prio(snsd_prio * snp, u_char prio);
snsd_prio *snsd_add_prio(snsd_prio ** head, u_char prio);
snsd_node *snsd_find_node_by_record(snsd_node * snd,
u_int record[MAX_IP_INT]);
uintptr_t record[MAX_IP_INT]);
snsd_node *snsd_add_node(snsd_node ** head, u_short * counter,
u_short max_records, u_int record[MAX_IP_INT]);
u_short max_records, uintptr_t record[MAX_IP_INT]);
snsd_node *snsd_add_mainip(snsd_service ** head, u_short * counter,
u_short max_records, u_int record[MAX_IP_INT]);
u_short max_records, uintptr_t record[MAX_IP_INT]);
void snsd_service_llist_del(snsd_service ** head);
void snsd_record_del_selected(snsd_service ** head, u_short * snd_counter,
snsd_service * selected);

View file

@ -67,7 +67,7 @@ ip_to_rfrom(inet_prefix rip, quadro_group * rip_quadg,
external_node = 1;
if (!external_node) {
iptomap((u_int) me.int_map, rip, me.cur_quadg.ipstart[1], &from);
iptomap((uintptr_t) me.int_map, rip, me.cur_quadg.ipstart[1], &from);
ret = rnode_find(me.cur_node, from);
} else {
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,
*/
if (!level) {
iptomap((u_int) me.int_map, rip, me.cur_quadg.ipstart[1],
iptomap((uintptr_t) me.int_map, rip, me.cur_quadg.ipstart[1],
&real_from);
from = node_from_pos(tracer[hops - 1].node, me.int_map);
} else {