From 4a93f5148d0289656dc2ecaefc7aa8e57d766e5b Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Wed, 6 May 2015 16:56:19 +0200 Subject: [PATCH 1/2] Fixed a number of compiler warnings --- core/lib/petsciiconv.c | 4 ++-- core/net/ip/resolv.c | 2 +- core/net/ip/slipdev.c | 2 +- core/net/ip/uip-nameserver.c | 2 ++ core/net/ipv6/uip-nd6.c | 18 +++++++++++------- core/net/mac/contikimac/contikimac.c | 19 ++++++------------- core/net/mac/nullrdc.c | 2 ++ examples/ipv6/rpl-collect/udp-sender.c | 2 +- 8 files changed, 26 insertions(+), 25 deletions(-) diff --git a/core/lib/petsciiconv.c b/core/lib/petsciiconv.c index 873c7c2c7..36e5b69f6 100644 --- a/core/lib/petsciiconv.c +++ b/core/lib/petsciiconv.c @@ -73,13 +73,13 @@ static unsigned char ascii2petscii[128] = { }; static unsigned int i; -static unsigned char *ptr; +static char *ptr; /*-----------------------------------------------------------------------------------*/ void petsciiconv_toascii(char *buf, unsigned int len) { - static char c; + char c; ptr = buf; for(i = len; i > 0; --i) { diff --git a/core/net/ip/resolv.c b/core/net/ip/resolv.c index 4a9999cca..58bda004d 100644 --- a/core/net/ip/resolv.c +++ b/core/net/ip/resolv.c @@ -787,7 +787,7 @@ newdata(void) static int8_t i; - register struct namemap *namemapptr; + register struct namemap *namemapptr = NULL; struct dns_answer *ans; diff --git a/core/net/ip/slipdev.c b/core/net/ip/slipdev.c index caab454ac..8bc688557 100644 --- a/core/net/ip/slipdev.c +++ b/core/net/ip/slipdev.c @@ -103,7 +103,7 @@ slipdev_send(void) ptr = &uip_buf[UIP_LLH_LEN]; for(i = 0; i < uip_len; ++i) { if(i == UIP_TCPIP_HLEN) { - ptr = (char *)uip_appdata; + ptr = (uint8_t *)uip_appdata; } c = *ptr++; switch(c) { diff --git a/core/net/ip/uip-nameserver.c b/core/net/ip/uip-nameserver.c index 6ced6b91e..367fe421d 100644 --- a/core/net/ip/uip-nameserver.c +++ b/core/net/ip/uip-nameserver.c @@ -56,8 +56,10 @@ typedef struct uip_nameserver_record { uint32_t lifetime; } uip_nameserver_record; +#if UIP_NAMESERVER_POOL_SIZE > 1 /** \brief Initialization flag */ static uint8_t initialized = 0; +#endif /** \name List and memory block * @{ diff --git a/core/net/ipv6/uip-nd6.c b/core/net/ipv6/uip-nd6.c index 701f458fa..72b1badfa 100644 --- a/core/net/ipv6/uip-nd6.c +++ b/core/net/ipv6/uip-nd6.c @@ -116,17 +116,20 @@ void uip_log(char *msg); #define UIP_ND6_OPT_RDNSS_BUF ((uip_nd6_opt_dns *)&uip_buf[uip_l2_l3_icmp_hdr_len + nd6_opt_offset]) /** @} */ +#if UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER static uint8_t nd6_opt_offset; /** Offset from the end of the icmpv6 header to the option in uip_buf*/ static uint8_t *nd6_opt_llao; /** Pointer to llao option in uip_buf */ +static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/ +static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */ +static uip_ds6_addr_t *addr; /** Pointer to an interface address */ +#endif /* UIP_ND6_SEND_NA || UIP_ND6_SEND_RA || !UIP_CONF_ROUTER */ #if !UIP_CONF_ROUTER // TBD see if we move it to ra_input static uip_nd6_opt_prefix_info *nd6_opt_prefix_info; /** Pointer to prefix information option in uip_buf */ static uip_ipaddr_t ipaddr; static uip_ds6_prefix_t *prefix; /** Pointer to a prefix list entry */ #endif -static uip_ds6_nbr_t *nbr; /** Pointer to a nbr cache entry*/ -static uip_ds6_defrt_t *defrt; /** Pointer to a router list entry */ -static uip_ds6_addr_t *addr; /** Pointer to an interface address */ + /*------------------------------------------------------------------*/ /* create a llao */ static void @@ -141,7 +144,7 @@ create_llao(uint8_t *llao, uint8_t type) { /*------------------------------------------------------------------*/ - +#if UIP_ND6_SEND_NA static void ns_input(void) { @@ -321,7 +324,7 @@ discard: uip_len = 0; return; } - +#endif /* UIP_ND6_SEND_NA */ /*------------------------------------------------------------------*/ @@ -387,6 +390,7 @@ uip_nd6_ns_output(uip_ipaddr_t * src, uip_ipaddr_t * dest, uip_ipaddr_t * tgt) PRINTF("\n"); return; } +#if UIP_ND6_SEND_NA /*------------------------------------------------------------------*/ /** * Neighbor Advertisement Processing @@ -556,7 +560,7 @@ discard: uip_len = 0; return; } - +#endif /* UIP_ND6_SEND_NA */ #if UIP_CONF_ROUTER #if UIP_ND6_SEND_RA @@ -859,7 +863,7 @@ ra_input(void) (uip_lladdr_t *)&nd6_opt_llao[UIP_ND6_OPT_DATA_OFFSET], 1, NBR_STALE); } else { - uip_lladdr_t *lladdr = uip_ds6_nbr_get_ll(nbr); + uip_lladdr_t *lladdr = (uip_lladdr_t *)uip_ds6_nbr_get_ll(nbr); if(nbr->state == NBR_INCOMPLETE) { nbr->state = NBR_STALE; } diff --git a/core/net/mac/contikimac/contikimac.c b/core/net/mac/contikimac/contikimac.c index cdfffc13b..32cc65bbf 100644 --- a/core/net/mac/contikimac/contikimac.c +++ b/core/net/mac/contikimac/contikimac.c @@ -341,7 +341,6 @@ powercycle(struct rtimer *t, void *ptr) while(1) { static uint8_t packet_seen; - static rtimer_clock_t t0; static uint8_t count; #if SYNC_CYCLE_STARTS @@ -365,7 +364,6 @@ powercycle(struct rtimer *t, void *ptr) packet_seen = 0; for(count = 0; count < CCA_COUNT_MAX; ++count) { - t0 = RTIMER_NOW(); if(we_are_sending == 0 && we_are_receiving_burst == 0) { powercycle_turn_radio_on(); /* Check if a packet is seen in the air. If so, we keep the @@ -499,7 +497,6 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, uint8_t got_strobe_ack = 0; int len; uint8_t is_broadcast = 0; - uint8_t is_reliable = 0; uint8_t is_known_receiver = 0; uint8_t collisions; int transmit_len; @@ -546,11 +543,6 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, packetbuf_addr(PACKETBUF_ADDR_RECEIVER)->u8[1]); #endif /* NETSTACK_CONF_WITH_IPV6 */ } - is_reliable = packetbuf_attr(PACKETBUF_ATTR_RELIABLE) -#if NETSTACK_CONF_WITH_RIME - || packetbuf_attr(PACKETBUF_ATTR_ERELIABLE) -#endif /* NETSTACK_CONF_WITH_RIME */ - ; if(!packetbuf_attr(PACKETBUF_ATTR_IS_CREATED_AND_SECURED)) { packetbuf_set_attr(PACKETBUF_ATTR_MAC_ACK, 1); @@ -672,11 +664,12 @@ send_packet(mac_callback_t mac_callback, void *mac_callback_ptr, { rtimer_clock_t wt; - rtimer_clock_t txtime; - int ret; - - txtime = RTIMER_NOW(); - ret = NETSTACK_RADIO.transmit(transmit_len); + rtimer_clock_t txtime = RTIMER_NOW(); +#if RDC_CONF_HARDWARE_ACK + int ret = NETSTACK_RADIO.transmit(transmit_len); +#else + NETSTACK_RADIO.transmit(transmit_len); +#endif #if RDC_CONF_HARDWARE_ACK /* For radios that block in the transmit routine and detect the diff --git a/core/net/mac/nullrdc.c b/core/net/mac/nullrdc.c index 3403b764e..7d14d26e0 100644 --- a/core/net/mac/nullrdc.c +++ b/core/net/mac/nullrdc.c @@ -264,11 +264,13 @@ send_list(mac_callback_t sent, void *ptr, struct rdc_buf_list *buf_list) static void packet_input(void) { +#if NULLRDC_SEND_802154_ACK int original_datalen; uint8_t *original_dataptr; original_datalen = packetbuf_datalen(); original_dataptr = packetbuf_dataptr(); +#endif #if NULLRDC_802154_AUTOACK if(packetbuf_datalen() == ACK_LEN) { diff --git a/examples/ipv6/rpl-collect/udp-sender.c b/examples/ipv6/rpl-collect/udp-sender.c index f216cbdcc..dd279cc7f 100644 --- a/examples/ipv6/rpl-collect/udp-sender.c +++ b/examples/ipv6/rpl-collect/udp-sender.c @@ -137,7 +137,7 @@ collect_common_send(void) /* Use parts of the IPv6 address as the parent address, in reversed byte order. */ parent.u8[LINKADDR_SIZE - 1] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 2]; parent.u8[LINKADDR_SIZE - 2] = nbr->ipaddr.u8[sizeof(uip_ipaddr_t) - 1]; - parent_etx = rpl_get_parent_rank((linkaddr_t *) uip_ds6_nbr_get_ll(nbr)) / 2; + parent_etx = rpl_get_parent_rank((uip_lladdr_t *) uip_ds6_nbr_get_ll(nbr)) / 2; } } rtmetric = dag->rank; From 5294cafd14b418437f7419ffec0a3d57a3cce5da Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Tue, 12 May 2015 09:25:22 +0200 Subject: [PATCH 2/2] petsciiconv.c: move variables from global to local --- core/lib/petsciiconv.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/lib/petsciiconv.c b/core/lib/petsciiconv.c index 36e5b69f6..a6eda5979 100644 --- a/core/lib/petsciiconv.c +++ b/core/lib/petsciiconv.c @@ -72,13 +72,12 @@ static unsigned char ascii2petscii[128] = { 0x58,0x59,0x5a,0xdb,0xdd,0xdd,0x5e,0xdf, }; -static unsigned int i; -static char *ptr; - /*-----------------------------------------------------------------------------------*/ void petsciiconv_toascii(char *buf, unsigned int len) { + unsigned int i; + char *ptr; char c; ptr = buf; @@ -108,6 +107,9 @@ petsciiconv_toascii(char *buf, unsigned int len) void petsciiconv_topetscii(char *buf, unsigned int len) { + unsigned int i; + char *ptr; + ptr = buf; for(i = len; i > 0; --i) { *ptr = ascii2petscii[*ptr & 0x7f];