Skip to content

Commit e4a9657

Browse files
author
Tero Heinonen
authored
Compiler warning clean-up (#1690)
Fixed compiler warnings.
1 parent a573bc4 commit e4a9657

File tree

12 files changed

+110
-94
lines changed

12 files changed

+110
-94
lines changed

source/6LoWPAN/Bootstraps/Generic/protocol_6lowpan_interface.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
8787
#endif
8888
}
8989
}
90-
uint16_t pan_id = cur->mac_parameters->pan_id;
90+
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
91+
pana_reset_values(cur->mac_parameters->pan_id);
92+
}
93+
9194
if (cur->interface_mode == INTERFACE_UP) {
9295
if (cur->mac_api) {
9396
mlme_reset_t reset;
@@ -105,9 +108,6 @@ static int8_t set_6lowpan_nwk_down(protocol_interface_info_entry_t *cur)
105108
reassembly_interface_reset(cur->id);
106109

107110
icmp_nd_routers_init();
108-
if (cur->lowpan_info & INTERFACE_NWK_BOOTSRAP_PANA_AUTHENTICATION) {
109-
pana_reset_values(pan_id);
110-
}
111111

112112
if (cur->pana_sec_info_temp) {
113113
ns_dyn_mem_free(cur->pana_sec_info_temp);

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,10 @@ static uint8_t mac_helper_header_security_aux_header_length(uint8_t keyIdmode) {
768768
switch (keyIdmode) {
769769
case MAC_KEY_ID_MODE_SRC8_IDX:
770770
header_length += 4; //64-bit key source first part
771+
/* fall through */
771772
case MAC_KEY_ID_MODE_SRC4_IDX:
772773
header_length += 4; //32-bit key source inline
774+
/* fall through */
773775
case MAC_KEY_ID_MODE_IDX:
774776
header_length += 1;
775777
break;

source/Common_Protocols/icmpv6.c

Lines changed: 76 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#define TRACE_GROUP "icmp"
4949

5050
static buffer_t *icmpv6_echo_request_handler(struct buffer *buf);
51-
static buffer_t *icmpv6_na_handler(struct buffer *buf);
5251

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

492490
proxy = true;
@@ -495,7 +493,7 @@ static buffer_t *icmpv6_ns_handler(buffer_t *buf)
495493
goto drop;
496494
}
497495

498-
if (!nd_proxy_enabled_for_downstream(cur->id) || !nd_proxy_target_address_validation(cur->id, target, &mesh_id)) {
496+
if (!nd_proxy_enabled_for_downstream(cur->id) || !nd_proxy_target_address_validation(cur->id, target)) {
499497
goto drop;
500498
}
501499
}
@@ -922,6 +920,80 @@ static buffer_t *icmpv6_redirect_handler(buffer_t *buf, protocol_interface_info_
922920
tr_warn("Redirect drop");
923921
return buffer_free(buf);
924922
}
923+
924+
static buffer_t *icmpv6_na_handler(buffer_t *buf)
925+
{
926+
protocol_interface_info_entry_t *cur;
927+
uint8_t *dptr = buffer_data_pointer(buf);
928+
uint8_t flags;
929+
const uint8_t *target;
930+
const uint8_t *tllao;
931+
if_address_entry_t *addr_entry;
932+
ipv6_neighbour_t *neighbour_entry;
933+
934+
//"Parse NA at IPv6\n");
935+
936+
if (buf->options.code != 0 || buf->options.hop_limit != 255) {
937+
goto drop;
938+
}
939+
940+
if (!icmpv6_options_well_formed_in_buffer(buf, 20)) {
941+
goto drop;
942+
}
943+
944+
// Skip the 4 reserved bytes
945+
flags = *dptr;
946+
dptr += 4;
947+
948+
// Note the target IPv6 address
949+
target = dptr;
950+
951+
if (addr_is_ipv6_multicast(target)) {
952+
goto drop;
953+
}
954+
955+
/* Solicited flag must be clear if sent to a multicast address */
956+
if (addr_is_ipv6_multicast(buf->dst_sa.address) && (flags & NA_S)) {
957+
goto drop;
958+
}
959+
960+
cur = buf->interface;
961+
962+
/* RFC 4862 5.4.4 DAD checks */
963+
addr_entry = addr_get_entry(cur, target);
964+
if (addr_entry) {
965+
if (addr_entry->tentative) {
966+
tr_debug("Received NA for our tentative address");
967+
addr_duplicate_detected(cur, target);
968+
} else {
969+
tr_debug("NA received for our own address: %s", trace_ipv6(target));
970+
}
971+
goto drop;
972+
}
973+
974+
if (cur->ipv6_neighbour_cache.recv_na_aro) {
975+
const uint8_t *aro = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_ADDR_REGISTRATION, 2);
976+
if (aro) {
977+
icmpv6_na_aro_handler(cur, aro, buf->dst_sa.address);
978+
}
979+
}
980+
981+
/* No need to create a neighbour cache entry if one doesn't already exist */
982+
neighbour_entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, target);
983+
if (!neighbour_entry) {
984+
goto drop;
985+
}
986+
987+
tllao = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_TGT_LL_ADDR, 0);
988+
if (!tllao || !cur->if_llao_parse(cur, tllao, &buf->dst_sa)) {
989+
buf->dst_sa.addr_type = ADDR_NONE;
990+
}
991+
992+
ipv6_neighbour_update_from_na(&cur->ipv6_neighbour_cache, neighbour_entry, flags, buf->dst_sa.addr_type, buf->dst_sa.address);
993+
994+
drop:
995+
return buffer_free(buf);
996+
}
925997
#endif // HAVE_IPV6_ND
926998

927999
buffer_t *icmpv6_up(buffer_t *buf)
@@ -994,7 +1066,7 @@ buffer_t *icmpv6_up(buffer_t *buf)
9941066

9951067
case ICMPV6_TYPE_INFO_ECHO_REPLY:
9961068
ipv6_neighbour_reachability_confirmation(buf->src_sa.address, buf->interface->id);
997-
/* no break */
1069+
/* fall through */
9981070

9991071
case ICMPV6_TYPE_ERROR_DESTINATION_UNREACH:
10001072
#ifdef HAVE_RPL_ROOT
@@ -1499,79 +1571,6 @@ buffer_t *icmpv6_build_na(protocol_interface_info_entry_t *cur, bool solicited,
14991571
return (buf);
15001572
}
15011573

1502-
static buffer_t *icmpv6_na_handler(buffer_t *buf)
1503-
{
1504-
protocol_interface_info_entry_t *cur;
1505-
uint8_t *dptr = buffer_data_pointer(buf);
1506-
uint8_t flags;
1507-
const uint8_t *target;
1508-
const uint8_t *tllao;
1509-
if_address_entry_t *addr_entry;
1510-
ipv6_neighbour_t *neighbour_entry;
1511-
1512-
//"Parse NA at IPv6\n");
1513-
1514-
if (buf->options.code != 0 || buf->options.hop_limit != 255) {
1515-
goto drop;
1516-
}
1517-
1518-
if (!icmpv6_options_well_formed_in_buffer(buf, 20)) {
1519-
goto drop;
1520-
}
1521-
1522-
// Skip the 4 reserved bytes
1523-
flags = *dptr;
1524-
dptr += 4;
1525-
1526-
// Note the target IPv6 address
1527-
target = dptr;
1528-
1529-
if (addr_is_ipv6_multicast(target)) {
1530-
goto drop;
1531-
}
1532-
1533-
/* Solicited flag must be clear if sent to a multicast address */
1534-
if (addr_is_ipv6_multicast(buf->dst_sa.address) && (flags & NA_S)) {
1535-
goto drop;
1536-
}
1537-
1538-
cur = buf->interface;
1539-
1540-
/* RFC 4862 5.4.4 DAD checks */
1541-
addr_entry = addr_get_entry(cur, target);
1542-
if (addr_entry) {
1543-
if (addr_entry->tentative) {
1544-
tr_debug("Received NA for our tentative address");
1545-
addr_duplicate_detected(cur, target);
1546-
} else {
1547-
tr_debug("NA received for our own address: %s", trace_ipv6(target));
1548-
}
1549-
goto drop;
1550-
}
1551-
1552-
if (cur->ipv6_neighbour_cache.recv_na_aro) {
1553-
const uint8_t *aro = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_ADDR_REGISTRATION, 2);
1554-
if (aro) {
1555-
icmpv6_na_aro_handler(cur, aro, buf->dst_sa.address);
1556-
}
1557-
}
1558-
1559-
/* No need to create a neighbour cache entry if one doesn't already exist */
1560-
neighbour_entry = ipv6_neighbour_lookup(&cur->ipv6_neighbour_cache, target);
1561-
if (!neighbour_entry) {
1562-
goto drop;
1563-
}
1564-
1565-
tllao = icmpv6_find_option_in_buffer(buf, 20, ICMPV6_OPT_TGT_LL_ADDR, 0);
1566-
if (!tllao || !cur->if_llao_parse(cur, tllao, &buf->dst_sa)) {
1567-
buf->dst_sa.addr_type = ADDR_NONE;
1568-
}
1569-
1570-
ipv6_neighbour_update_from_na(&cur->ipv6_neighbour_cache, neighbour_entry, flags, buf->dst_sa.addr_type, buf->dst_sa.address);
1571-
1572-
drop:
1573-
return buffer_free(buf);
1574-
}
15751574
#endif // HAVE_IPV6_ND
15761575

15771576
#ifdef HAVE_IPV6_ND

source/Common_Protocols/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ tcp_error tcp_session_abort(tcp_session_t *tcp_session)
559559
case TCP_STATE_FIN_WAIT_2:
560560
case TCP_STATE_CLOSE_WAIT:
561561
tcp_session_send_reset_to_abort_connection(tcp_session);
562-
/* no break */
562+
/* fall through */
563563
case TCP_STATE_LISTEN:
564564
case TCP_STATE_SYN_SENT:
565565
tcp_session_delete_with_error(tcp_session, SOCKET_CONNECTION_RESET);

source/Core/include/ns_buffer.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,12 +340,20 @@ struct socket *buffer_socket_set(buffer_t *buf, struct socket *socket);
340340
/** Removes z amount of bytes from the begining of buffer
341341
* uint8_t *buffer_data_strip_header(buffer_t *x, uint16_t z)
342342
* */
343-
#define buffer_data_strip_header(x,z) ((x)->buf_ptr += (z), buffer_data_pointer_after_adjustment(x))
343+
static inline uint8_t *buffer_data_strip_header(buffer_t *x, uint16_t z)
344+
{
345+
x->buf_ptr += z;
346+
return buffer_data_pointer_after_adjustment(x);
347+
}
344348

345349
/** Adds z amount of bytes to the begining of buffer check if this is allowed using buffer_headroom method.
346350
* uint8_t *buffer_data_reserve_header(buffer_t *x, uint16_t z)
347351
* */
348-
#define buffer_data_reserve_header(x,z) ((x)->buf_ptr -= (z), buffer_data_pointer_after_adjustment(x))
352+
static inline uint8_t *buffer_data_reserve_header(buffer_t *x, uint16_t z)
353+
{
354+
x->buf_ptr -= z;
355+
return buffer_data_pointer_after_adjustment(x);
356+
}
349357

350358
/** append 1 byte to data*/
351359
#define buffer_push_uint8(x, z) do {\

source/MAC/IEEE802_15_4/mac_header_helper_functions.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ uint8_t mac_header_security_aux_header_length(uint8_t security_level, uint8_t ke
5858
switch (keyIdmode) {
5959
case MAC_KEY_ID_MODE_SRC8_IDX:
6060
header_length += 4; //64-bit key source first part
61+
/* fall through */
6162
case MAC_KEY_ID_MODE_SRC4_IDX:
6263
header_length += 4; //32-bit key source inline
64+
/* fall through */
6365
case MAC_KEY_ID_MODE_IDX:
6466
header_length += 1;
6567
break;
@@ -128,8 +130,10 @@ void mac_header_security_parameter_set(mac_aux_security_header_t *header, const
128130

129131
case MAC_KEY_ID_MODE_SRC8_IDX:
130132
keysource_len += 4; //64-bit key source first part
133+
/* fall through */
131134
case MAC_KEY_ID_MODE_SRC4_IDX:
132135
keysource_len += 4; //32-bit key source inline
136+
/* fall through */
133137
case MAC_KEY_ID_MODE_IDX:
134138
//Security header + 32-bit security counter + Key index
135139
header->KeyIndex = frame_setup->KeyIndex;
@@ -198,10 +202,12 @@ void mac_header_security_components_read(mac_pre_parsed_frame_t *buffer, mlme_se
198202
break;
199203
case MAC_KEY_ID_MODE_SRC8_IDX:
200204
key_source_len += 4;
205+
/* fall through */
201206
case MAC_KEY_ID_MODE_SRC4_IDX:
202207
key_source_len += 4;
203208
memcpy(security_params->Keysource, ptr, key_source_len);
204209
ptr += key_source_len;
210+
/* fall through */
205211
case MAC_KEY_ID_MODE_IDX:
206212
security_params->KeyIndex = *ptr;
207213
break;

source/MPL/mpl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ buffer_t *mpl_control_handler(buffer_t *buf, protocol_interface_info_entry_t *cu
685685
// by its colour not being flipped.
686686
// This is equivalent to having a "mentioned" flag, except we don't have
687687
// to have a separate "reset" loop.
688-
bool new_colour = --domain->colour; // smart-alec binary flip
688+
domain->colour = !domain->colour;
689+
bool new_colour = domain->colour;
689690

690691
while (ptr < end) {
691692
if (end - ptr < 2) {

source/Service_Libs/fhss/fhss_beacon_tasklet.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ static void fhss_beacon_tasklet_func(arm_event_s* event)
6868
if (!fhss_structure) {
6969
return;
7070
}
71+
#ifdef FEA_TRACE_SUPPORT
7172
uint8_t parent_address[8];
73+
#endif
7274
fhss_clear_active_event(fhss_structure, event->event_type);
7375
// skip the init event as there will be a timer event after
7476
if (event->event_type == FHSS_TIMER_EVENT) {

source/Service_Libs/nd_proxy/nd_proxy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,11 +434,11 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id)
434434
return false;
435435
}
436436

437-
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr)
437+
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address)
438438
{
439439
nd_proxy_downstream_list_s *downstream;
440440
nd_proxy_connected_list_s *upstream = proxy_upstream_conection_get(upstream_id);
441-
*downstream_id_ptr = -1;
441+
442442
if (!upstream) {
443443
return false;
444444
}
@@ -447,7 +447,6 @@ bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, in
447447
downstream = proxy_cache_downstream_interface_get(downstream_entry->id, &downstream_interface_list);
448448
if (downstream) {
449449
if (downstream->nd_proxy_validation(downstream_entry->id, address) == 0) {
450-
*downstream_id_ptr = downstream_entry->id;
451450
return true;
452451
}
453452
}

source/Service_Libs/nd_proxy/nd_proxy.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id);
125125
*\return true Address validated behind downstream_id_ptr interface
126126
*\return false Unknown address for this proxy
127127
*/
128-
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr);
128+
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address);
129129
/**
130130
* Downstream interface validate prefix route on Link status from connected Upstream interface
131131
*
@@ -147,9 +147,9 @@ NS_DUMMY_DEFINITIONS_OK
147147
#define nd_proxy_upstream_interface_unregister(interface_id) -1
148148
#define nd_proxy_enabled_for_downstream(interface_id) false
149149
#define nd_proxy_enabled_for_upstream(interface_id) false
150-
#define nd_proxy_target_address_validation(upstream_id, address, downstream_id_ptr) false
150+
#define nd_proxy_target_address_validation(upstream_id, address) false
151151
#define nd_proxy_upstream_route_onlink(downstream_id, address) false
152-
#define nd_proxy_target_address_validation(upstream_id, address, downstream_id_ptr) false
152+
153153
#endif /* HAVE_ND_PROXY */
154154

155155
#endif /* ND_PROXY_H_ */

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ static void ipv6_destination_cache_forget_neighbour(const ipv6_neighbour_t *neig
7373
static void ipv6_destination_release(ipv6_destination_t *dest);
7474
static void ipv6_route_table_remove_router(int8_t interface_id, const uint8_t *addr, ipv6_route_src_t source);
7575
static uint16_t total_metric(const ipv6_route_t *route);
76-
static void trace_debug_print(const char *fmt, ...);
7776
static uint8_t ipv6_route_table_count_source(int8_t interface_id, ipv6_route_src_t source);
7877
static void ipv6_route_table_remove_last_one_from_source(int8_t interface_id, ipv6_route_src_t source);
7978
static uint8_t ipv6_route_table_get_max_entries(int8_t interface_id, ipv6_route_src_t source);
@@ -758,7 +757,7 @@ void ipv6_neighbour_cache_fast_timer(ipv6_neighbour_cache_t *cache, uint16_t tic
758757
ipv6_neighbour_set_state(cache, cur, IP_NEIGHBOUR_UNREACHABLE);
759758
}
760759
}
761-
/* no break */
760+
/* fall through */
762761
case IP_NEIGHBOUR_UNREACHABLE:
763762
if (cur->retrans_count < 0xFF) {
764763
cur->retrans_count++;

test/nanostack/unittest/stub/nd_proxy_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ bool nd_proxy_enabled_for_upstream(int8_t interface_id)
5656
return false;
5757
}
5858

59-
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address, int8_t *downstream_id_ptr)
59+
bool nd_proxy_target_address_validation(int8_t upstream_id, uint8_t *address)
6060
{
6161
return false;
6262
}

0 commit comments

Comments
 (0)