Skip to content

Commit

Permalink
Compiler warning clean-up (ARMmbed#1690)
Browse files Browse the repository at this point in the history
Fixed compiler warnings.
  • Loading branch information
Tero Heinonen authored May 3, 2018
1 parent a573bc4 commit e4a9657
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
#endif
}
}
uint16_t pan_id = cur->mac_parameters->pan_id;
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
pana_reset_values(cur->mac_parameters->pan_id);
}

if (cur->interface_mode == INTERFACE_UP) {
if (cur->mac_api) {
mlme_reset_t reset;
Expand All @@ -105,9 +108,6 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
reassembly_interface_reset(cur->id);

icmp_nd_routers_init();
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
pana_reset_values(pan_id);
}

if (cur->pana_sec_info_temp) {
ns_dyn_mem_free(cur->pana_sec_info_temp);
Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/MAC/mac_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,10 @@ static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode) {
switch (keyIdmode) {
case MAC_KEY_ID_MODE_SRC8_IDX:
header_length += 4; //64-bit key source first part
/* fall through */
case MAC_KEY_ID_MODE_SRC4_IDX:
header_length += 4; //32-bit key source inline
/* fall through */
case MAC_KEY_ID_MODE_IDX:
header_length += 1;
break;
Expand Down
153 changes: 76 additions & 77 deletions source/Common_Protocols/icmpv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#define TRACE_GROUP "icmp"

static buffer_t *icmpv6_echo_request_handler(struct buffer *buf);
static buffer_t *icmpv6_na_handler(struct buffer *buf);

/* Check to see if a message is recognisable ICMPv6, and if so, fill in code/type */
/* This used ONLY for the e.1 + e.2 tests in RFC 4443, to try to avoid ICMPv6 error loops */
Expand Down Expand Up @@ -486,7 +485,6 @@ static buffer_t *icmpv6_ns_handler(buffer_t *buf)
* interface, which we should only do in the whiteboard case.
*/
if (addr_interface_address_compare(cur, target) != 0) {
int8_t mesh_id = -1;
//tr_debug("Received NS for proxy %s", trace_ipv6(target));

proxy = true;
Expand All @@ -495,7 +493,7 @@ static buffer_t *icmpv6_ns_handler(buffer_t *buf)
goto drop;
}

if (!nd_proxy_enabled_for_downstream(cur->id) || !nd_proxy_target_address_validation(cur->id, target, &mesh_id)) {
if (!nd_proxy_enabled_for_downstream(cur->id) || !nd_proxy_target_address_validation(cur->id, target)) {
goto drop;
}
}
Expand Down Expand Up @@ -922,6 +920,80 @@ static buffer_t *icmpv6_redirect_handler(buffer_t *buf, protocol_interface_info_
tr_warn("Redirect drop");
return buffer_free(buf);
}

static buffer_t *icmpv6_na_handler(buffer_t *buf)
{
protocol_interface_info_entry_t *cur;
uint8_t *dptr = buffer_data_pointer(buf);
uint8_t flags;
const uint8_t *target;
const uint8_t *tllao;
if_address_entry_t *addr_entry;
ipv6_neighbour_t *neighbour_entry;

//"Parse NA at IPv6\n");

if (buf->options.code != 0 || buf->options.hop_limit != 255) {
goto drop;
}

if (!icmpv6_options_well_formed_in_buffer(buf, 20)) {
goto drop;
}

// Skip the 4 reserved bytes
flags = *dptr;
dptr += 4;

// Note the target IPv6 address
target = dptr;

if (addr_is_ipv6_multicast(target)) {
goto drop;
}

/* Solicited flag must be clear if sent to a multicast address */
if (addr_is_ipv6_multicast(buf->dst_sa.address) && (flags & NA_S)) {
goto drop;
}

cur = buf->interface;

/* RFC 4862 5.4.4 DAD checks */
addr_entry = addr_get_entry(cur, target);
if (addr_entry) {
if (addr_entry->tentative) {
tr_debug("Received NA for our tentative address");
addr_duplicate_detected(cur, target);
} else {
tr_debug("NA received for our own address: %s", trace_ipv6(target));
}
goto drop;
}

if (cur->ipv6_neighbour_cache.recv_na_aro) {
const uint8_t *aro = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_ADDR_REGISTRATION, 2);
if (aro) {
icmpv6_na_aro_handler(cur, aro, buf->dst_sa.address);
}
}

/* No need to create a neighbour cache entry if one doesn't already exist */
neighbour_entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, target);
if (!neighbour_entry) {
goto drop;
}

tllao = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_TGT_LL_ADDR, 0);
if (!tllao || !cur->if_llao_parse(cur, tllao, &buf->dst_sa)) {
buf->dst_sa.addr_type = ADDR_NONE;
}

ipv6_neighbour_update_from_na(&cur->ipv6_neighbour_cache, neighbour_entry, flags, buf->dst_sa.addr_type, buf->dst_sa.address);

drop:
return buffer_free(buf);
}
#endif // HAVE_IPV6_ND

buffer_t *icmpv6_up(buffer_t *buf)
Expand Down Expand Up @@ -994,7 +1066,7 @@ buffer_t *icmpv6_up(buffer_t *buf)

case ICMPV6_TYPE_INFO_ECHO_REPLY:
ipv6_neighbour_reachability_confirmation(buf->src_sa.address, buf->interface->id);
/* no break */
/* fall through */

case ICMPV6_TYPE_ERROR_DESTINATION_UNREACH:
#ifdef HAVE_RPL_ROOT
Expand Down Expand Up @@ -1499,79 +1571,6 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
return (buf);
}

static buffer_t *icmpv6_na_handler(buffer_t *buf)
{
protocol_interface_info_entry_t *cur;
uint8_t *dptr = buffer_data_pointer(buf);
uint8_t flags;
const uint8_t *target;
const uint8_t *tllao;
if_address_entry_t *addr_entry;
ipv6_neighbour_t *neighbour_entry;

//"Parse NA at IPv6\n");

if (buf->options.code != 0 || buf->options.hop_limit != 255) {
goto drop;
}

if (!icmpv6_options_well_formed_in_buffer(buf, 20)) {
goto drop;
}

// Skip the 4 reserved bytes
flags = *dptr;
dptr += 4;

// Note the target IPv6 address
target = dptr;

if (addr_is_ipv6_multicast(target)) {
goto drop;
}

/* Solicited flag must be clear if sent to a multicast address */
if (addr_is_ipv6_multicast(buf->dst_sa.address) && (flags & NA_S)) {
goto drop;
}

cur = buf->interface;

/* RFC 4862 5.4.4 DAD checks */
addr_entry = addr_get_entry(cur, target);
if (addr_entry) {
if (addr_entry->tentative) {
tr_debug("Received NA for our tentative address");
addr_duplicate_detected(cur, target);
} else {
tr_debug("NA received for our own address: %s", trace_ipv6(target));
}
goto drop;
}

if (cur->ipv6_neighbour_cache.recv_na_aro) {
const uint8_t *aro = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_ADDR_REGISTRATION, 2);
if (aro) {
icmpv6_na_aro_handler(cur, aro, buf->dst_sa.address);
}
}

/* No need to create a neighbour cache entry if one doesn't already exist */
neighbour_entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, target);
if (!neighbour_entry) {
goto drop;
}

tllao = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_TGT_LL_ADDR, 0);
if (!tllao || !cur->if_llao_parse(cur, tllao, &buf->dst_sa)) {
buf->dst_sa.addr_type = ADDR_NONE;
}

ipv6_neighbour_update_from_na(&cur->ipv6_neighbour_cache, neighbour_entry, flags, buf->dst_sa.addr_type, buf->dst_sa.address);

drop:
return buffer_free(buf);
}
#endif // HAVE_IPV6_ND

#ifdef HAVE_IPV6_ND
Expand Down
2 changes: 1 addition & 1 deletion source/Common_Protocols/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ tcp_error tcp_session_abort(tcp_session_t *tcp_session)
case TCP_STATE_FIN_WAIT_2:
case TCP_STATE_CLOSE_WAIT:
tcp_session_send_reset_to_abort_connection(tcp_session);
/* no break */
/* fall through */
case TCP_STATE_LISTEN:
case TCP_STATE_SYN_SENT:
tcp_session_delete_with_error(tcp_session, SOCKET_CONNECTION_RESET);
Expand Down
12 changes: 10 additions & 2 deletions source/Core/include/ns_buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,20 @@ struct socket *buffer_socket_set(buffer_t *buf, struct socket *socket);
/** Removes z amount of bytes from the begining of buffer
* uint8_t *buffer_data_strip_header(buffer_t *x, uint16_t z)
* */
#define buffer_data_strip_header(x,z) ((x)->buf_ptr += (z), buffer_data_pointer_after_adjustment(x))
static inline uint8_t *buffer_data_strip_header(buffer_t *x, uint16_t z)
{
x->buf_ptr += z;
return buffer_data_pointer_after_adjustment(x);
}

/** Adds z amount of bytes to the begining of buffer check if this is allowed using buffer_headroom method.
* uint8_t *buffer_data_reserve_header(buffer_t *x, uint16_t z)
* */
#define buffer_data_reserve_header(x,z) ((x)->buf_ptr -= (z), buffer_data_pointer_after_adjustment(x))
static inline uint8_t *buffer_data_reserve_header(buffer_t *x, uint16_t z)
{
x->buf_ptr -= z;
return buffer_data_pointer_after_adjustment(x);
}

/** append 1 byte to data*/
#define buffer_push_uint8(x, z) do {\
Expand Down
6 changes: 6 additions & 0 deletions source/MAC/IEEE802_15_4/mac_header_helper_functions.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ uint8_t mac_header_security_aux_header_length(uint8_t security_level, uint8_t ke
switch (keyIdmode) {
case MAC_KEY_ID_MODE_SRC8_IDX:
header_length += 4; //64-bit key source first part
/* fall through */
case MAC_KEY_ID_MODE_SRC4_IDX:
header_length += 4; //32-bit key source inline
/* fall through */
case MAC_KEY_ID_MODE_IDX:
header_length += 1;
break;
Expand Down Expand Up @@ -128,8 +130,10 @@ void mac_header_security_parameter_set(mac_aux_security_header_t *header, const

case MAC_KEY_ID_MODE_SRC8_IDX:
keysource_len += 4; //64-bit key source first part
/* fall through */
case MAC_KEY_ID_MODE_SRC4_IDX:
keysource_len += 4; //32-bit key source inline
/* fall through */
case MAC_KEY_ID_MODE_IDX:
//Security header + 32-bit security counter + Key index
header->KeyIndex = frame_setup->KeyIndex;
Expand Down Expand Up @@ -198,10 +202,12 @@ void mac_header_security_components_read(mac_pre_parsed_frame_t *buffer, mlme_se
break;
case MAC_KEY_ID_MODE_SRC8_IDX:
key_source_len += 4;
/* fall through */
case MAC_KEY_ID_MODE_SRC4_IDX:
key_source_len += 4;
memcpy(security_params->Keysource, ptr, key_source_len);
ptr += key_source_len;
/* fall through */
case MAC_KEY_ID_MODE_IDX:
security_params->KeyIndex = *ptr;
break;
Expand Down
3 changes: 2 additions & 1 deletion source/MPL/mpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,8 @@ buffer_t *mpl_control_handler(buffer_t *buf, protocol_interface_info_entry_t *cu
// by its colour not being flipped.
// This is equivalent to having a "mentioned" flag, except we don't have
// to have a separate "reset" loop.
bool new_colour = --domain->colour; // smart-alec binary flip
domain->colour = !domain->colour;
bool new_colour = domain->colour;

while (ptr < end) {
if (end - ptr < 2) {
Expand Down
2 changes: 2 additions & 0 deletions source/Service_Libs/fhss/fhss_beacon_tasklet.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ static void fhss_beacon_tasklet_func(arm_event_s* event)
if (!fhss_structure) {
return;
}
#ifdef FEA_TRACE_SUPPORT
uint8_t parent_address[8];
#endif
fhss_clear_active_event(fhss_structure, event->event_type);
// skip the init event as there will be a timer event after
if (event->event_type == FHSS_TIMER_EVENT) {
Expand Down
5 changes: 2 additions & 3 deletions source/Service_Libs/nd_proxy/nd_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -434,11 +434,11 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id)
return false;
}

bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr)
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address)
{
nd_proxy_downstream_list_s *downstream;
nd_proxy_connected_list_s *upstream = proxy_upstream_conection_get(upstream_id);
*downstream_id_ptr = -1;

if (!upstream) {
return false;
}
Expand All @@ -447,7 +447,6 @@ bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, in
downstream = proxy_cache_downstream_interface_get(downstream_entry->id, &downstream_interface_list);
if (downstream) {
if (downstream->nd_proxy_validation(downstream_entry->id, address) == 0) {
*downstream_id_ptr = downstream_entry->id;
return true;
}
}
Expand Down
6 changes: 3 additions & 3 deletions source/Service_Libs/nd_proxy/nd_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id);
*\return true Address validated behind downstream_id_ptr interface
*\return false Unknown address for this proxy
*/
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr);
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address);
/**
* Downstream interface validate prefix route on Link status from connected Upstream interface
*
Expand All @@ -147,9 +147,9 @@ NS_DUMMY_DEFINITIONS_OK
#define nd_proxy_upstream_interface_unregister(interface_id) -1
#define nd_proxy_enabled_for_downstream(interface_id) false
#define nd_proxy_enabled_for_upstream(interface_id) false
#define nd_proxy_target_address_validation(upstream_id, address, downstream_id_ptr) false
#define nd_proxy_target_address_validation(upstream_id, address) false
#define nd_proxy_upstream_route_onlink(downstream_id, address) false
#define nd_proxy_target_address_validation(upstream_id, address, downstream_id_ptr) false

#endif /* HAVE_ND_PROXY */

#endif /* ND_PROXY_H_ */
3 changes: 1 addition & 2 deletions source/ipv6_stack/ipv6_routing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ static void ipv6_destination_cache_forget_neighbour(const ipv6_neighbour_t *neig
static void ipv6_destination_release(ipv6_destination_t *dest);
static void ipv6_route_table_remove_router(int8_t interface_id, const uint8_t *addr, ipv6_route_src_t source);
static uint16_t total_metric(const ipv6_route_t *route);
static void trace_debug_print(const char *fmt, ...);
static uint8_t ipv6_route_table_count_source(int8_t interface_id, ipv6_route_src_t source);
static void ipv6_route_table_remove_last_one_from_source(int8_t interface_id, ipv6_route_src_t source);
static uint8_t ipv6_route_table_get_max_entries(int8_t interface_id, ipv6_route_src_t source);
Expand Down Expand Up @@ -758,7 +757,7 @@ void ipv6_neighbour_cache_fast_timer(ipv6_neighbour_cache_t *cache, uint16_t tic
ipv6_neighbour_set_state(cache, cur, IP_NEIGHBOUR_UNREACHABLE);
}
}
/* no break */
/* fall through */
case IP_NEIGHBOUR_UNREACHABLE:
if (cur->retrans_count < 0xFF) {
cur->retrans_count++;
Expand Down
2 changes: 1 addition & 1 deletion test/nanostack/unittest/stub/nd_proxy_stub.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id)
return false;
}

bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr)
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address)
{
return false;
}
Expand Down

0 comments on commit e4a9657

Please sign in to comment.