Skip to content

Commit d5cf8d5

Browse files
author
Arto Kinnunen
authored
Clean ARMC6/GCC compiler warnings (#2278)
Clean ARMC6/GCC compiler warnings from all nanostack configurations.
1 parent 807632d commit d5cf8d5

File tree

18 files changed

+72
-15
lines changed

18 files changed

+72
-15
lines changed

source/6LoWPAN/MAC/mac_helper.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -887,6 +887,7 @@ int8_t mac_helper_key_link_frame_counter_set(int8_t interface_id, uint32_t seq_p
887887

888888
void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index, uint8_t *mac64)
889889
{
890+
(void) mac64;
890891
if (!mac_api) {
891892
return;
892893
}

source/6LoWPAN/MAC/mac_response_handler.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ void mcps_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *d
120120
void mcps_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
121121
{
122122
(void)api;
123+
(void)data;
123124
tr_info("MCPS Data Purge confirm status %u, for handle %u", data->status, data->msduHandle);
124125
}
125126

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,6 +1754,8 @@ void nd_6lowpan_set_radv_params(protocol_interface_info_entry_t *cur_interface)
17541754
cur_interface->adv_retrans_timer = nd_params.ra_retrans_timer;
17551755
cur_interface->max_initial_rtr_adv_interval = nd_params.ra_interval_min;
17561756
cur_interface->max_initial_rtr_advertisements = nd_params.ra_transmits;
1757+
#else
1758+
(void) cur_interface;
17571759
#endif
17581760
}
17591761
#endif // HAVE_6LOWPAN_ND

source/6LoWPAN/Thread/thread_test_api.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,10 @@ int thread_test_version_set(int8_t interface_id, uint8_t version)
643643

644644
int thread_test_pbbr_response_override_set(int8_t interface_id, uint8_t dua_status, uint8_t dua_count, uint8_t ba_failure_count)
645645
{
646-
#ifdef HAVE_THREAD
646+
#if defined(HAVE_THREAD) && defined(HAVE_THREAD_V2) && defined(HAVE_THREAD_BORDER_ROUTER)
647647
(void)interface_id;
648648
thread_bbr_commercial_status_override_set(dua_status, dua_count, ba_failure_count);
649649
return 0;
650-
651650
#else
652651
(void)interface_id;
653652
(void)dua_status;

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545

4646
#define RPL_INSTANCE_ID 1
4747

48-
static uint8_t current_instance_id = RPL_INSTANCE_ID;
49-
5048
#ifdef HAVE_WS_BORDER_ROUTER
5149

50+
static uint8_t current_instance_id = RPL_INSTANCE_ID;
51+
5252
#define WS_ULA_LIFETIME 24*3600
5353
#define WS_ROUTE_LIFETIME WS_ULA_LIFETIME
5454
#define WS_DHCP_ADDRESS_LIFETIME 2*3600

source/6LoWPAN/ws/ws_pae_auth.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ void ws_pae_auth_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_
232232
#else
233233

234234
#define ws_pae_auth_init(interface_ptr, gtks, next_gtks, certs, timer_settings) 1
235-
#define ws_pae_auth_timing_adjust(timing) 1
235+
#define ws_pae_auth_timing_adjust(timing)
236236
#define ws_pae_auth_addresses_set(interface_ptr, local_port, remote_addr, remote_port) 1
237237
#define ws_pae_auth_delete NULL
238238
#define ws_pae_auth_cb_register(interface_ptr, hash_set, nw_key_insert, nw_key_index_set) {(void) hash_set;}

source/6LoWPAN/ws/ws_pae_nvm_data.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ nvm_tlv_entry_t *ws_pae_buffer_allocate(void)
5757

5858
void ws_pae_nvm_store_nw_info_tlv_create(nvm_tlv_entry_t *tlv_entry, uint16_t pan_id, char *nw_name, sec_prot_gtk_keys_t *gtks)
5959
{
60-
60+
int len;
6161
tlv_entry->tag = PAE_NVM_NW_INFO_TAG;
6262
tlv_entry->len = PAE_NVM_NW_INFO_LEN;
6363

@@ -66,7 +66,13 @@ void ws_pae_nvm_store_nw_info_tlv_create(nvm_tlv_entry_t *tlv_entry, uint16_t pa
6666
tlv = common_write_16_bit(pan_id, tlv);
6767

6868
memset(tlv, 0, 33);
69-
strncpy((char *)tlv, nw_name, 32);
69+
// use strnlen & memset instead of strncpy to avoid gcc warning:
70+
// call to __builtin___strncpy_chk will always overflow destination buffer [-Werror]
71+
len = strlen(nw_name);
72+
if (len > 32) {
73+
len = 32;
74+
}
75+
memcpy((char *)tlv, nw_name, len);
7076
tlv += 33;
7177

7278
for (uint8_t i = 0; i < GTK_NUM; i++) {

source/Common_Protocols/icmpv6_radv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,9 @@ void icmpv6_stop_router_advertisements(protocol_interface_info_entry_t *cur, con
325325
*/
326326
static void icmpv6_send_ra(protocol_interface_info_entry_t *cur, const uint8_t *dest, const uint8_t *abro)
327327
{
328+
#ifndef HAVE_RPL
329+
(void) abro;
330+
#endif
328331
if (cur->nwk_id == IF_6LoWPAN) {
329332
nd_ra_build_by_abro(abro, dest, cur);
330333
} else {

source/Common_Protocols/ipv6.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,9 @@ static buffer_t *ipv6_tunnel_exit(buffer_t *buf, uint8_t *payload)
773773
static buffer_t *ipv6_handle_options(buffer_t *buf, protocol_interface_info_entry_t *cur, uint8_t *ptr, uint8_t nh, uint16_t payload_length, uint16_t *hdrlen_out, const sockaddr_t *ll_src, bool pre_fragment)
774774
{
775775
(void) nh;
776+
#ifndef HAVE_RPL
777+
(void) ll_src;
778+
#endif
776779
if (payload_length < 2) {
777780
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_HDR_ERR, 4);
778781
}
@@ -853,6 +856,9 @@ static buffer_t *ipv6_handle_options(buffer_t *buf, protocol_interface_info_entr
853856

854857
static buffer_t *ipv6_handle_routing_header(buffer_t *buf, protocol_interface_info_entry_t *cur, uint8_t *ptr, uint16_t payload_length, uint16_t *hdrlen_out, bool *forward_out, bool pre_fragment)
855858
{
859+
#ifndef HAVE_RPL
860+
(void) forward_out;
861+
#endif
856862
if (buf->options.ll_security_bypass_rx) {
857863
tr_warn("Routing header: Security check fail");
858864
protocol_stats_update(STATS_IP_RX_DROP, 1);

source/Core/ns_socket.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,16 @@ void socket_release(socket_t *socket)
287287
if (tcp_info(socket->inet_pcb)) {
288288
/* This may trigger a reset if pending data. Do it first so you
289289
* get just the reset, rather than a FIN. */
290-
tcp_session_shutdown_read(tcp_info(socket->inet_pcb));
290+
tcp_error sock_status = tcp_session_shutdown_read(tcp_info(socket->inet_pcb));
291291
/* This can also cause TCP deletion */
292292
if (tcp_info(socket->inet_pcb)) {
293-
tcp_session_close(tcp_info(socket->inet_pcb));
293+
sock_status = tcp_session_close(tcp_info(socket->inet_pcb));
294294
}
295295
if (tcp_info(socket->inet_pcb)) {
296296
tcp_socket_released(tcp_info(socket->inet_pcb));
297297
}
298+
// prevent warning "statement with no effect" when TCP is disabled
299+
(void) sock_status;
298300
} else {
299301
/* Unbind the internet control block - ensures users are not prevented
300302
* from binding a new socket to the same port if the socket lingers
@@ -1362,8 +1364,10 @@ int16_t socket_buffer_sendmsg(int8_t sid, buffer_t *buf, const struct ns_msghdr
13621364

13631365
protocol_push(buf);
13641366

1367+
#ifndef NO_TCP
13651368
/* TCP jumps back to here */
13661369
success:
1370+
#endif
13671371
if (flags & NS_MSG_LEGACY0) {
13681372
return 0;
13691373
} else {

0 commit comments

Comments
 (0)