Commit f36431b4 authored by Maxime Vincent's avatar Maxime Vincent

Improved C89 compatability (e.g. Watcom compiler)

parent cd50e73b
......@@ -19,7 +19,7 @@ STRIP?=0
RTOS?=0
GENERIC?=0
PTHREAD?=0
ADDRESS_SANITIZER?=1
ADDRESS_SANITIZER?=0
# Default compiled-in protocols
#
......@@ -134,7 +134,10 @@ endif
ifeq ($(ARCH),faulty)
CFLAGS+=-DFAULTY -DUNIT_TEST
CFLAGS+=-fsanitize=address -fno-omit-frame-pointer
ifeq ($(ADDRESS_SANITIZER),1)
CFLAGS+=-fsanitize=address
endif
CFLAGS+=-fno-omit-frame-pointer
UNITS_OBJ+=test/pico_faulty.o
TEST_OBJ+=test/pico_faulty.o
DUMMY_EXTRA+=test/pico_faulty.o
......
This diff is collapsed.
......@@ -19,6 +19,11 @@
# define PEDANTIC_STRUCT_DEF __packed struct
# define PACKED_UNION_DEF __packed union
# define WEAK
#elif defined __WATCOMC__
# define PACKED_STRUCT_DEF _Packed struct
# define PEDANTIC_STRUCT_DEF struct
# define PACKED_UNION_DEF _Packed union
# define WEAK
#else
# define PACKED_STRUCT_DEF struct __attribute__((packed))
# define PEDANTIC_STRUCT_DEF struct
......
......@@ -27,7 +27,7 @@ extern const uint8_t PICO_ETHADDR_ALL[6];
#endif
static int max_arp_reqs = PICO_ARP_MAX_RATE;
static struct pico_frame *frames_queued[PICO_ARP_MAX_PENDING] = { };
static struct pico_frame *frames_queued[PICO_ARP_MAX_PENDING] = { 0 };
static void pico_arp_queued_trigger(void)
{
......
......@@ -491,7 +491,7 @@ static void pico_dhcp_client_recv_params(struct pico_dhcp_client_cookie *dhcpc,
static int recv_offer(struct pico_dhcp_client_cookie *dhcpc, uint8_t *buf)
{
struct pico_dhcp_hdr *hdr = (struct pico_dhcp_hdr *)buf;
struct pico_dhcp_opt *opt = (struct pico_dhcp_opt *)hdr->options;
struct pico_dhcp_opt *opt = DHCP_OPT(hdr,0);
pico_dhcp_client_recv_params(dhcpc, opt);
if ((dhcpc->event != PICO_DHCP_MSG_OFFER) || !dhcpc->server_id.addr || !dhcpc->netmask.addr || !dhcpc->lease_time)
......@@ -510,7 +510,7 @@ static int recv_offer(struct pico_dhcp_client_cookie *dhcpc, uint8_t *buf)
static int recv_ack(struct pico_dhcp_client_cookie *dhcpc, uint8_t *buf)
{
struct pico_dhcp_hdr *hdr = (struct pico_dhcp_hdr *)buf;
struct pico_dhcp_opt *opt = (struct pico_dhcp_opt *)hdr->options;
struct pico_dhcp_opt *opt = DHCP_OPT(hdr,0);
struct pico_ip4 address = {
0
};
......@@ -767,15 +767,14 @@ static int16_t pico_dhcp_client_opt_parse(void *ptr, uint16_t len)
{
uint32_t optlen = len - (uint32_t)sizeof(struct pico_dhcp_hdr);
struct pico_dhcp_hdr *hdr = (struct pico_dhcp_hdr *)ptr;
struct pico_dhcp_opt *opt = NULL;
struct pico_dhcp_opt *opt = DHCP_OPT(hdr,0);
if (hdr->dhcp_magic != PICO_DHCPD_MAGIC_COOKIE)
return -1;
if (!pico_dhcp_are_options_valid(hdr->options, (int32_t)optlen))
if (!pico_dhcp_are_options_valid(opt, (int32_t)optlen))
return -1;
opt = (struct pico_dhcp_opt *)hdr->options;
do {
if (opt->code == PICO_DHCP_OPT_MSGTYPE)
return opt->ext.msg_type.type;
......@@ -811,7 +810,7 @@ static int8_t pico_dhcp_client_msg(struct pico_dhcp_client_cookie *dhcpc, uint8_
}
/* specific options */
offset = (uint16_t)(offset + pico_dhcp_opt_maxmsgsize(&hdr->options[offset], DHCP_CLIENT_MAXMSGZISE));
offset = (uint16_t)(offset + pico_dhcp_opt_maxmsgsize(DHCP_OPT(hdr,offset), DHCP_CLIENT_MAXMSGZISE));
break;
case PICO_DHCP_MSG_REQUEST:
......@@ -824,10 +823,10 @@ static int8_t pico_dhcp_client_msg(struct pico_dhcp_client_cookie *dhcpc, uint8_
}
/* specific options */
offset = (uint16_t)(offset + pico_dhcp_opt_maxmsgsize(&hdr->options[offset], DHCP_CLIENT_MAXMSGZISE));
offset = (uint16_t)(offset + pico_dhcp_opt_maxmsgsize(DHCP_OPT(hdr,offset), DHCP_CLIENT_MAXMSGZISE));
if (dhcpc->state == DHCP_CLIENT_STATE_REQUESTING) {
offset = (uint16_t)(offset + pico_dhcp_opt_reqip(&hdr->options[offset], &dhcpc->address));
offset = (uint16_t)(offset + pico_dhcp_opt_serverid(&hdr->options[offset], &dhcpc->server_id));
offset = (uint16_t)(offset + pico_dhcp_opt_reqip(DHCP_OPT(hdr,offset), &dhcpc->address));
offset = (uint16_t)(offset + pico_dhcp_opt_serverid(DHCP_OPT(hdr,offset), &dhcpc->server_id));
}
break;
......@@ -837,9 +836,9 @@ static int8_t pico_dhcp_client_msg(struct pico_dhcp_client_cookie *dhcpc, uint8_
}
/* common options */
offset = (uint16_t)(offset + pico_dhcp_opt_msgtype(&hdr->options[offset], msg_type));
offset = (uint16_t)(offset + pico_dhcp_opt_paramlist(&hdr->options[offset]));
offset = (uint16_t)(offset + pico_dhcp_opt_end(&hdr->options[offset]));
offset = (uint16_t)(offset + pico_dhcp_opt_msgtype(DHCP_OPT(hdr,offset), msg_type));
offset = (uint16_t)(offset + pico_dhcp_opt_paramlist(DHCP_OPT(hdr,offset)));
offset = (uint16_t)(offset + pico_dhcp_opt_end(DHCP_OPT(hdr,offset)));
switch (dhcpc->state)
{
......
......@@ -15,6 +15,9 @@
#define PICO_DHCPD_MAGIC_COOKIE (long_be(0x63825363))
#define PICO_DHCP_HTYPE_ETH 1
/* Macro to get DHCP option field */
#define DHCP_OPT(hdr,off) ((struct pico_dhcp_opt *)(((uint8_t *)hdr)+sizeof(struct pico_dhcp_hdr) + off))
/* flags */
#define PICO_DHCP_FLAG_BROADCAST 0x8000
......@@ -102,7 +105,6 @@ PACKED_STRUCT_DEF pico_dhcp_hdr
char hostname[64];
char bootp_filename[128];
uint32_t dhcp_magic;
uint8_t options[0];
};
PACKED_STRUCT_DEF pico_dhcp_opt
......
......@@ -256,14 +256,14 @@ static void dhcpd_make_reply(struct pico_dhcp_server_negotiation *dhcpn, uint8_t
memcpy(hdr->hwaddr, dhcpn->hwaddr.addr, PICO_SIZE_ETH);
/* options */
offset += pico_dhcp_opt_msgtype(&hdr->options[offset], msg_type);
offset += pico_dhcp_opt_serverid(&hdr->options[offset], &dhcpn->dhcps->server_ip);
offset += pico_dhcp_opt_leasetime(&hdr->options[offset], dhcpn->dhcps->lease_time);
offset += pico_dhcp_opt_netmask(&hdr->options[offset], &dhcpn->dhcps->netmask);
offset += pico_dhcp_opt_router(&hdr->options[offset], &dhcpn->dhcps->server_ip);
offset += pico_dhcp_opt_broadcast(&hdr->options[offset], &broadcast);
offset += pico_dhcp_opt_dns(&hdr->options[offset], &dns);
offset += pico_dhcp_opt_end(&hdr->options[offset]);
offset += pico_dhcp_opt_msgtype(DHCP_OPT(hdr,offset), msg_type);
offset += pico_dhcp_opt_serverid(DHCP_OPT(hdr,offset), &dhcpn->dhcps->server_ip);
offset += pico_dhcp_opt_leasetime(DHCP_OPT(hdr,offset), dhcpn->dhcps->lease_time);
offset += pico_dhcp_opt_netmask(DHCP_OPT(hdr,offset), &dhcpn->dhcps->netmask);
offset += pico_dhcp_opt_router(DHCP_OPT(hdr,offset), &dhcpn->dhcps->server_ip);
offset += pico_dhcp_opt_broadcast(DHCP_OPT(hdr,offset), &broadcast);
offset += pico_dhcp_opt_dns(DHCP_OPT(hdr,offset), &dns);
offset += pico_dhcp_opt_end(DHCP_OPT(hdr,offset));
if (dhcpn->bcast == 0)
destination.addr = hdr->yiaddr;
......@@ -324,7 +324,7 @@ static inline void dhcps_make_reply_to_discover_or_request(struct pico_dhcp_serv
static inline void dhcps_parse_options_loop(struct pico_dhcp_server_negotiation *dhcpn, struct pico_dhcp_hdr *hdr)
{
struct pico_dhcp_opt *opt = (struct pico_dhcp_opt *)hdr->options;
struct pico_dhcp_opt *opt = DHCP_OPT(hdr,0);
uint8_t msgtype = 0;
struct pico_ip4 reqip = {
0
......@@ -347,7 +347,7 @@ static void pico_dhcp_server_recv(struct pico_socket *s, uint8_t *buf, uint32_t
struct pico_dhcp_server_negotiation *dhcpn = NULL;
struct pico_device *dev = NULL;
if (!pico_dhcp_are_options_valid(hdr->options, optlen))
if (!pico_dhcp_are_options_valid(DHCP_OPT(hdr,0), optlen))
return;
dev = pico_ipv4_link_find(&s->local_addr.ip4);
......@@ -395,9 +395,8 @@ int pico_dhcp_server_initiate(struct pico_dhcp_server_setting *setting)
int pico_dhcp_server_destroy(struct pico_device *dev)
{
struct pico_dhcp_server_setting *found, test = {
.dev = dev,
};
struct pico_dhcp_server_setting *found, test = { 0 };
test.dev = dev;
found = pico_tree_findKey(&DHCPSettings, &test);
if (!found) {
pico_err = PICO_ERR_ENOENT;
......
......@@ -444,9 +444,8 @@ void
pico_dns_ipv6_set_ptr( const char *ip, char *dst )
{
int i = 0, j = 0;
struct pico_ip6 ip6 = {
.addr = {}
};
struct pico_ip6 ip6;
memset(&ip6, 0, sizeof(struct pico_ip6));
pico_string_to_ipv6(ip, ip6.addr);
for (i = 15; i >= 0; i--) {
if ((j + 3) > 64) return; /* Don't want j to go out of bounds */
......
......@@ -87,4 +87,5 @@ int
pico_dns_sd_kv_vector_add( kv_vector *vector, char *key, char *value );
#endif /* _INCLUDE_PICO_DNS_SD */
\ No newline at end of file
#endif /* _INCLUDE_PICO_DNS_SD */
......@@ -313,7 +313,7 @@ int pico_icmp6_neighbor_solicitation(struct pico_device *dev, struct pico_ip6 *d
icmp6_hdr->msg.info.neigh_sol.target = *dst;
if (type != PICO_ICMP6_ND_DAD) {
opt = (struct pico_icmp6_opt_lladdr *)icmp6_hdr->msg.info.neigh_sol.options;
opt = (struct pico_icmp6_opt_lladdr *)(((uint8_t *)&icmp6_hdr->msg.info.neigh_sol) + sizeof(struct neigh_sol_s));
opt->type = PICO_ND_OPT_LLADDR_SRC;
opt->len = 1;
memcpy(opt->addr.mac.addr, dev->eth->mac.addr, PICO_SIZE_ETH);
......@@ -376,7 +376,7 @@ int pico_icmp6_neighbor_advertisement(struct pico_frame *f, struct pico_ip6 *tar
* sending a response for a random time between 0 and MAX_ANYCAST_DELAY_TIME seconds.
*/
opt = (struct pico_icmp6_opt_lladdr *)icmp6_hdr->msg.info.neigh_adv.options;
opt = (struct pico_icmp6_opt_lladdr *)(((uint8_t *)&icmp6_hdr->msg.info.neigh_adv) + sizeof(struct neigh_adv_s));
opt->type = PICO_ND_OPT_LLADDR_TGT;
opt->len = 1;
memcpy(opt->addr.mac.addr, f->dev->eth->mac.addr, PICO_SIZE_ETH);
......@@ -414,7 +414,7 @@ int pico_icmp6_router_solicitation(struct pico_device *dev, struct pico_ip6 *src
icmp6_hdr->code = 0;
if (!pico_ipv6_is_unspecified(src->addr)) {
lladdr = (struct pico_icmp6_opt_lladdr *)icmp6_hdr->msg.info.router_sol.options;
lladdr = (struct pico_icmp6_opt_lladdr *)(((uint8_t *)&icmp6_hdr->msg.info.router_sol) + sizeof(struct router_sol_s));
lladdr->type = PICO_ND_OPT_LLADDR_SRC;
lladdr->len = 1;
memcpy(lladdr->addr.mac.addr, dev->eth->mac.addr, PICO_SIZE_ETH);
......@@ -458,7 +458,7 @@ int pico_icmp6_router_advertisement(struct pico_device *dev, struct pico_ip6 *ds
icmp6_hdr->code = 0;
icmp6_hdr->msg.info.router_adv.life_time = short_be(45);
icmp6_hdr->msg.info.router_adv.hop = 64;
nxt_opt = (uint8_t *) icmp6_hdr->msg.info.router_adv.options;
nxt_opt = (uint8_t *)&icmp6_hdr->msg.info.router_adv + sizeof(struct router_adv_s);
prefix = (struct pico_icmp6_opt_prefix *)nxt_opt;
prefix->type = PICO_ND_OPT_PREFIX;
......
......@@ -111,19 +111,15 @@ PACKED_STRUCT_DEF pico_icmp6_hdr {
PACKED_UNION_DEF icmp6_err_u {
PEDANTIC_STRUCT_DEF dest_unreach_s {
uint32_t unused;
uint8_t data[0];
} dest_unreach;
PEDANTIC_STRUCT_DEF pkt_too_big_s {
uint32_t mtu;
uint8_t data[0];
} pkt_too_big;
PEDANTIC_STRUCT_DEF time_exceeded_s {
uint32_t unused;
uint8_t data[0];
} time_exceeded;
PEDANTIC_STRUCT_DEF param_problem_s {
uint32_t ptr;
uint8_t data[0];
} param_problem;
} err;
......@@ -132,16 +128,13 @@ PACKED_STRUCT_DEF pico_icmp6_hdr {
PEDANTIC_STRUCT_DEF echo_request_s {
uint16_t id;
uint16_t seq;
uint8_t data[0];
} echo_request;
PEDANTIC_STRUCT_DEF echo_reply_s {
uint16_t id;
uint16_t seq;
uint8_t data[0];
} echo_reply;
PEDANTIC_STRUCT_DEF router_sol_s {
uint32_t unused;
uint8_t options[0];
} router_sol;
PEDANTIC_STRUCT_DEF router_adv_s {
uint8_t hop;
......@@ -149,23 +142,19 @@ PACKED_STRUCT_DEF pico_icmp6_hdr {
uint16_t life_time;
uint32_t reachable_time;
uint32_t retrans_time;
uint8_t options[0];
} router_adv;
PEDANTIC_STRUCT_DEF neigh_sol_s {
uint32_t unused;
struct pico_ip6 target;
uint8_t options[0];
} neigh_sol;
PEDANTIC_STRUCT_DEF neigh_adv_s {
uint32_t rsor;
struct pico_ip6 target;
uint8_t options[0];
} neigh_adv;
PEDANTIC_STRUCT_DEF redirect_s {
uint32_t reserved;
struct pico_ip6 target;
struct pico_ip6 dest;
uint8_t options[0];
} redirect;
PEDANTIC_STRUCT_DEF mld_s {
uint16_t max_resp_time;
......@@ -218,7 +207,6 @@ PACKED_STRUCT_DEF pico_icmp6_opt_redirect
uint8_t len;
uint16_t res0;
uint32_t res1;
uint8_t data[0];
};
PACKED_STRUCT_DEF pico_icmp6_opt_rdnss
......@@ -227,14 +215,13 @@ PACKED_STRUCT_DEF pico_icmp6_opt_rdnss
uint8_t len;
uint16_t res0;
uint32_t lifetime;
struct pico_ip6 addr[];
struct pico_ip6 *addr;
};
PACKED_STRUCT_DEF pico_icmp6_opt_na
{
uint8_t type;
uint8_t len;
uint8_t options[0];
};
struct pico_icmp6_stats
......
......@@ -96,7 +96,6 @@ PACKED_STRUCT_DEF igmpv3_query {
uint8_t rsq;
uint8_t qqic;
uint16_t sources;
uint32_t source_addr[0];
};
PACKED_STRUCT_DEF igmpv3_group_record {
......@@ -104,7 +103,6 @@ PACKED_STRUCT_DEF igmpv3_group_record {
uint8_t aux;
uint16_t sources;
uint32_t mcast_group;
uint32_t source_addr[0];
};
PACKED_STRUCT_DEF igmpv3_report {
......@@ -113,7 +111,6 @@ PACKED_STRUCT_DEF igmpv3_report {
uint16_t crc;
uint16_t res1;
uint16_t groups;
struct igmpv3_group_record record[0];
};
struct igmp_parameters {
......@@ -918,16 +915,17 @@ igmp3_report:
report->res1 = 0;
report->groups = short_be(1);
record = &report->record[0];
record = (struct igmpv3_group_record *)(((uint8_t *)report) + sizeof(struct igmpv3_report));
record->type = record_type;
record->aux = 0;
record->sources = short_be(sources);
record->mcast_group = p->mcast_group.addr;
if (IGMPFilter && !pico_tree_empty(IGMPFilter)) {
uint32_t *source_addr = (uint32_t *)((uint8_t *)record + sizeof(struct igmpv3_group_record));
i = 0;
pico_tree_foreach(index, IGMPFilter)
{
record->source_addr[i] = ((struct pico_ip4 *)index->keyValue)->addr;
source_addr[i] = ((struct pico_ip4 *)index->keyValue)->addr;
i++;
}
}
......
......@@ -401,9 +401,9 @@ uint32_t pico_ipv4_filter_add(struct pico_device *dev, uint8_t proto,
int pico_ipv4_filter_del(uint32_t filter_id)
{
struct filter_node *node = NULL;
struct filter_node dummy = {
.filter_id = filter_id
};
struct filter_node dummy = { 0 };
dummy.filter_id = filter_id;
if((node = pico_tree_delete(&filter_tree, &dummy)) == NULL)
{
ipf_dbg("ipfilter> failed to delete filter :%d\n", filter_id);
......
......@@ -516,7 +516,7 @@ static int pico_ipv6_process_hopbyhop(struct pico_ipv6_exthdr *hbh, struct pico_
uint8_t must_align = 1;
IGNORE_PARAMETER(f);
option = hbh->ext.hopbyhop.options;
option = ((uint8_t *)&hbh->ext.hopbyhop) + sizeof(struct hopbyhop_s);
len = (uint8_t)HBH_LEN(hbh);
ipv6_dbg("IPv6: hop by hop extension header length %u\n", len + 2);
while (len) {
......@@ -597,7 +597,7 @@ static int pico_ipv6_process_destopt(struct pico_ipv6_exthdr *destopt, struct pi
uint8_t len = 0, optlen = 0;
opt_ptr += (uint32_t)(2u); /* Skip Dest_opts header */
IGNORE_PARAMETER(f);
option = destopt->ext.destopt.options;
option = ((uint8_t *)&destopt->ext.destopt) + sizeof(struct destopt_s);
len = (uint8_t)(((destopt->ext.destopt.len + 1) << 3) - 2); /* len in bytes, minus nxthdr and len byte */
ipv6_dbg("IPv6: destination option extension header length %u\n", len + 2);
while (len) {
......
......@@ -40,7 +40,6 @@ PACKED_STRUCT_DEF pico_ipv6_hdr {
uint8_t hop;
struct pico_ip6 src;
struct pico_ip6 dst;
uint8_t extensions[0];
};
PACKED_STRUCT_DEF pico_ipv6_pseudo_hdr
......@@ -77,7 +76,6 @@ union pico_link {
struct pico_ipv6_hbhoption {
uint8_t type;
uint8_t len;
uint8_t options[0];
};
#ifdef PICO_SUPPORT_MCAST
struct pico_ipv6_mcast_group {
......@@ -90,7 +88,6 @@ struct pico_ipv6_mcast_group {
struct pico_ipv6_destoption {
uint8_t type;
uint8_t len;
uint8_t options[0];
};
struct pico_ipv6_route
......@@ -108,12 +105,10 @@ PACKED_STRUCT_DEF pico_ipv6_exthdr {
PACKED_UNION_DEF ipv6_ext_u {
PEDANTIC_STRUCT_DEF hopbyhop_s {
uint8_t len;
uint8_t options[0];
} hopbyhop;
PEDANTIC_STRUCT_DEF destopt_s {
uint8_t len;
uint8_t options[0];
} destopt;
PEDANTIC_STRUCT_DEF routing_s {
......
......@@ -22,7 +22,7 @@
#define nd_dbg(...) do {} while(0)
static struct pico_frame *frames_queued_v6[PICO_ND_MAX_FRAMES_QUEUED] = { };
static struct pico_frame *frames_queued_v6[PICO_ND_MAX_FRAMES_QUEUED] = { 0 };
enum pico_ipv6_neighbor_state {
......@@ -220,7 +220,7 @@ static int neigh_options(struct pico_frame *f, struct pico_icmp6_opt_lladdr *opt
icmp6_hdr = (struct pico_icmp6_hdr *)f->transport_hdr;
optlen = f->transport_len - PICO_ICMP6HDR_NEIGH_ADV_SIZE;
if (optlen)
option = icmp6_hdr->msg.info.neigh_adv.options;
option = ((uint8_t *)&icmp6_hdr->msg.info.neigh_adv) + sizeof(struct neigh_adv_s);
while (optlen > 0) {
type = ((struct pico_icmp6_opt_lladdr *)option)->type;
......@@ -526,7 +526,7 @@ static int neigh_adv_option_len_validity_check(struct pico_frame *f)
* - All included options have a length that is greater than zero.
*/
icmp6_hdr = (struct pico_icmp6_hdr *)f->transport_hdr;
opt = icmp6_hdr->msg.info.neigh_adv.options;
opt = ((uint8_t *)&icmp6_hdr->msg.info.neigh_adv) + sizeof(struct neigh_adv_s);
while(optlen > 0) {
int opt_size = (opt[1] << 3);
......@@ -685,7 +685,7 @@ static int radv_process(struct pico_frame *f)
hdr = (struct pico_ipv6_hdr *)f->net_hdr;
icmp6_hdr = (struct pico_icmp6_hdr *)f->transport_hdr;
optlen = f->transport_len - PICO_ICMP6HDR_ROUTER_ADV_SIZE;
opt_start = (uint8_t *)icmp6_hdr->msg.info.router_adv.options;
opt_start = ((uint8_t *)&icmp6_hdr->msg.info.router_adv) + sizeof(struct router_adv_s);
nxtopt = opt_start;
while (optlen > 0) {
......@@ -715,7 +715,7 @@ static int radv_process(struct pico_frame *f)
if (long_be(prefix->pref_lifetime) > long_be(prefix->val_lifetime))
goto ignore_opt_prefix;
if (prefix->val_lifetime <= 0)
if (prefix->val_lifetime == 0)
goto ignore_opt_prefix;
......
......@@ -445,17 +445,6 @@ pico_mdns_question_create( const char *url,
/* MARK: ^ MDNS QUESTIONS */
/* MARK: v MDNS RECORDS */
#define PICO_MDNS_RECORD_DECLARE(name) \
struct pico_mdns_record (name) = { \
&(struct pico_dns_record) { \
NULL, \
&(struct pico_dns_record_suffix) { 0, 1, 0, 0 }, \
NULL, \
0 \
}, \
0, 0, 0 \
}
/* ****************************************************************************
* Just makes a hardcopy from a single mDNS resource record.
*
......@@ -545,9 +534,14 @@ pico_mdns_rtree_find_name_type( pico_mdns_rtree *tree,
uint8_t copy )
{
PICO_MDNS_RTREE_DECLARE(hits);
PICO_MDNS_RECORD_DECLARE(test);
struct pico_dns_record_suffix test_dns_suffix = { 0, 1, 0, 0 };
struct pico_dns_record test_dns_record = { 0 };
struct pico_mdns_record test = { 0 };
struct pico_tree_node *node = NULL;
struct pico_mdns_record *record = NULL;
test_dns_record.rsuffix = &test_dns_suffix;
test.record = &test_dns_record;
/* Check params */
if (!name || !tree) {
......@@ -619,9 +613,14 @@ pico_mdns_rtree_del_name_type( pico_mdns_rtree *tree,
char *name,
uint16_t type )
{
PICO_MDNS_RECORD_DECLARE(test);
struct pico_tree_node *node = NULL, *next = NULL;
struct pico_mdns_record *record = NULL;
struct pico_dns_record_suffix test_dns_suffix = { 0, 1, 0, 0 };
struct pico_dns_record test_dns_record = { 0 };
struct pico_mdns_record test = { 0 };
test_dns_record.rsuffix = &test_dns_suffix;
test.record = &test_dns_record;
/* Check params */
if (!name || !tree) {
......
......@@ -79,7 +79,7 @@ static uint8_t *pico_mld_fill_hopbyhop(struct pico_ipv6_hbhoption *hbh) {
hbh->type = PICO_PROTO_ICMP6;
hbh->len=0;
// ROUTER ALERT, RFC2711
p = hbh->options;
p = (uint8_t *)hbh + sizeof(struct pico_ipv6_hbhoption);
*(p++) = PICO_IPV6_EXTHDR_OPT_ROUTER_ALERT;
*(p++) = PICO_IPV6_EXTHDR_OPT_ROUTER_ALERT_DATALEN;
*(p++) = 0;
......@@ -98,7 +98,8 @@ static int pico_mld_check_hopbyhop(struct pico_ipv6_hbhoption *hbh) {
return -1;
if(hbh->type != options[0] || hbh->len != options[1])
return -1;
p = hbh->options;
p = (uint8_t *)hbh + sizeof(struct pico_ipv6_hbhoption);
for(i=0; i<MLD_ROUTER_ALERT_LEN-2; i++) {
if( *(p+i) != options[i+2])
return -1;
......
......@@ -88,9 +88,9 @@ static void pico_slaacv4_cancel_timers(struct slaacv4_cookie *tmp)
static void pico_slaacv4_send_announce_timer(pico_time now, void *arg)
{
struct slaacv4_cookie *tmp = (struct slaacv4_cookie *)arg;
struct pico_ip4 netmask = {
.addr = long_be(0xFFFF0000)
};
struct pico_ip4 netmask = { 0 };
netmask.addr = long_be(0xFFFF0000);
(void)now;
if (tmp->announce_nb < ANNOUNCE_NB)
......
......@@ -132,9 +132,8 @@ static void *peek_segment(struct pico_tcp_queue *tq, uint32_t seq)
}
else
{
struct tcp_input_segment dummy = {
.seq = seq
};
struct tcp_input_segment dummy = { 0 };
dummy.seq = seq;
return pico_tree_findKey(&tq->pool, &dummy);
}
......
......@@ -234,7 +234,7 @@ static int devloop_in(struct pico_device *dev, int loop_score)
{
struct pico_frame *f;
while(loop_score > 0) {
if (dev->q_in->frames <= 0)
if (dev->q_in->frames == 0)
break;
/* Receive */
......@@ -270,7 +270,7 @@ static int devloop_out(struct pico_device *dev, int loop_score)
{
struct pico_frame *f;
while(loop_score > 0) {
if (dev->q_out->frames <= 0)
if (dev->q_out->frames == 0)
break;
/* Device dequeue + send */
......
......@@ -24,7 +24,7 @@ void pico_frame_discard(struct pico_frame *f)
return;
(*f->usage_count)--;
if (*f->usage_count <= 0) {
if (*f->usage_count == 0) {
if (f->flags & PICO_FRAME_FLAG_EXT_USAGE_COUNTER)
PICO_FREE(f->usage_count);
......
......@@ -53,7 +53,7 @@ static int proto_loop_in(struct pico_protocol *proto, int loop_score)
{
struct pico_frame *f;
while(loop_score > 0) {
if (proto->q_in->frames <= 0)
if (proto->q_in->frames == 0)
break;
f = pico_dequeue(proto->q_in);
......@@ -68,7 +68,7 @@ static int proto_loop_out(struct pico_protocol *proto, int loop_score)
{
struct pico_frame *f;
while(loop_score > 0) {
if (proto->q_out->frames <= 0)
if (proto->q_out->frames == 0)
break;
f = pico_dequeue(proto->q_out);
......
......@@ -726,7 +726,7 @@ int32_t pico_stack_recv(struct pico_device *dev, uint8_t *buffer, uint32_t len)
{
struct pico_frame *f;
int32_t ret;
if (len <= 0)
if (len == 0)
return -1;
f = pico_frame_alloc(len);
......@@ -762,7 +762,7 @@ static int32_t _pico_stack_recv_zerocopy(struct pico_device *dev, uint8_t *buffe
{
struct pico_frame *f;
int ret;
if (len <= 0)
if (len == 0)
return -1;
f = pico_frame_alloc_skeleton(len, ext_buffer);
......
......@@ -41,7 +41,7 @@ START_TEST(tc_pico_mld_check_hopbyhop)
hbh->type = PICO_PROTO_ICMP6;
hbh->len = 0;
for(test = 0; test<7; test++) {
p = hbh->options;
p = (uint8_t *)hbh + sizeof(struct pico_ipv6_hbhoption);
for(i = 0; i<6; i++ ) {
if(i != test)
*(p++) = options[i+2];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment