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 {

source/MAC/IEEE802_15_4/mac_mlme.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ int8_t mac_mlme_set_req(protocol_interface_rf_mac_setup_s *rf_mac_setup, const m
783783
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_RF_CONFIGURATION, (uint8_t *) set_req->value_pointer);
784784
mac_mlme_set_symbol_rate(rf_mac_setup);
785785
phy_rf_channel_configuration_s *config_params = (phy_rf_channel_configuration_s *)set_req->value_pointer;
786+
(void) config_params; // unused variable if traces disabled
786787
tr_info("RF config update:");
787788
tr_info("Frequency(ch0): %"PRIu32"Hz", config_params->channel_0_center_frequency);
788789
tr_info("Channel spacing: %"PRIu32"Hz", config_params->channel_spacing);

source/Security/TLS/tls_lib.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suit
229229
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
230230
thep->client_knows_standard_ecc_ciphersuite = true;
231231
/* no break */
232+
/* fall through */
232233
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_COMPAT:
233234
tr_debug("Client Sup ECC");
234235
ret_val |= SEC_CIPHERSUITE_ECC;

source/Security/protocols/key_sec_prot/key_sec_prot.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ static int8_t key_sec_prot_tx_status_ind(sec_prot_t *prot, sec_prot_tx_status_e
318318

319319
// Indicates TX failure
320320
if (tx_status == SEC_PROT_TX_ERR_TX_NO_ACK) {
321-
sec_prot_result_set(&data->common, KMP_RESULT_ERR_TX_NO_ACK);
321+
sec_prot_result_set(&data->common, SEC_RESULT_ERR_TX_NO_ACK);
322322
} else if (tx_status != SEC_PROT_TX_OK) {
323323
// Indicates other failure
324-
sec_prot_result_set(&data->common, KMP_RESULT_ERR_UNSPEC);
324+
sec_prot_result_set(&data->common, SEC_RESULT_ERR_UNSPEC);
325325
}
326326
prot->state_machine_call(prot);
327327
return 0;

source/Service_Libs/fhss/fhss.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,7 +1385,9 @@ static void fhss_beacon_tasklet_func(arm_event_s *event)
13851385
if (!fhss_structure) {
13861386
return;
13871387
}
1388+
#ifdef FEA_TRACE_SUPPORT
13881389
uint8_t parent_address[8];
1390+
#endif
13891391
fhss_clear_active_event(fhss_structure, event->event_type);
13901392
// skip the init event as there will be a timer event after
13911393
if (event->event_type == FHSS_TIMER_EVENT) {

source/libNET/src/net_6lowpan_parameter_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ int8_t net_6lowpan_nd_parameter_set(const nd_parameters_s *p)
6565

6666
return 0;
6767
#else
68+
(void) p;
6869
return -2;
6970
#endif
7071
}
@@ -89,6 +90,8 @@ int8_t net_6lowpan_nd_timer_base_tick_set(uint8_t base_tick_x_100ms)
8990
}
9091

9192
nd_base_tick = base_tick_x_100ms;
93+
#else
94+
(void) base_tick_x_100ms;
9295
#endif
9396
return 0;
9497
}
@@ -103,5 +106,7 @@ void net_6lowpan_nd_parameter_read(nd_parameters_s *p)
103106
{
104107
#ifdef HAVE_6LOWPAN_ND
105108
*p = nd_params;
109+
#else
110+
(void) p;
106111
#endif
107112
}

source/libNET/src/net_load_balance.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ int8_t net_load_balance_network_switch_cb_set(int8_t interface_id, net_load_bala
146146

147147
return load_balance_network_switch_cb_set(interface_ptr->lb_api, network_switch_notify);
148148
#else
149+
(void) interface_id;
150+
(void) network_switch_notify;
149151
return -1;
150152
#endif
151153
}
152154

153155

154-
int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon_interval)
156+
int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon_interval)
155157
{
156158
#ifdef HAVE_6LOWPAN_ND
157159
protocol_interface_info_entry_t *interface_ptr = protocol_stack_interface_info_get_by_id(interface_id);
@@ -188,6 +190,8 @@ int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon
188190

189191
return 0;
190192
#else
193+
(void) interface_id;
194+
(void) enable_periodic_beacon_interval;
191195
return -1;
192196
#endif
193197
}
@@ -205,6 +209,7 @@ int8_t net_load_balance_delete(int8_t interface_id)
205209

206210
return load_balance_delete(lb_api);
207211
#else
212+
(void) interface_id;
208213
return -1;
209214
#endif
210215
}
@@ -223,6 +228,9 @@ int8_t net_load_balance_threshold_set(int8_t interface_id, uint8_t threshold_min
223228

224229
return load_balance_network_threshold_set(interface_ptr->lb_api, threshold_min, threshold_max);
225230
#else
231+
(void) interface_id;
232+
(void) threshold_min;
233+
(void) threshold_max;
226234
return -1;
227235
#endif
228236
}
@@ -259,8 +267,10 @@ void net_load_balance_internal_state_activate(protocol_interface_info_entry_t *i
259267
set_req.value_pointer = &state;
260268
set_req.value_size = sizeof(bool);
261269
interface_ptr->mac_api->mlme_req(interface_ptr->mac_api, MLME_SET, &set_req);
270+
#else
271+
(void) interface_ptr;
272+
(void) state;
262273
#endif
263-
264274
}
265275

266276
#ifdef HAVE_RPL
@@ -361,6 +371,8 @@ int8_t net_load_balance_set_max_probability(int8_t interface_id, uint8_t max_p)
361371

362372
return load_balance_set_max_probability(interface_ptr->lb_api, max_p);
363373
#else
374+
(void) interface_id;
375+
(void) max_p;
364376
return -1;
365377
#endif
366378
}

source/libNET/src/ns_net.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,10 @@ int8_t arm_nwk_6lowpan_gp_address_mode(int8_t interface_id, net_6lowpan_gp_addre
400400

401401
return 0;
402402
#else
403+
(void) interface_id;
404+
(void) mode;
405+
(void) short_address_base;
406+
(void) define_new_short_address_at_DAD;
403407
return -2;
404408
#endif
405409
}
@@ -895,14 +899,17 @@ int8_t arm_pana_client_key_pull(int8_t interface_id)
895899
return pana_client_key_pull(interface_id);
896900
}
897901

898-
int8_t arm_nwk_link_layer_security_mode(int8_t interface_id, net_6lowpan_link_layer_sec_mode_e mode, uint8_t sec_level, const net_link_layer_psk_security_info_s *psk_key_info)
902+
int8_t arm_nwk_link_layer_security_mode(int8_t interface_id, net_6lowpan_link_layer_sec_mode_e mode, uint8_t sec_level, const net_link_layer_psk_security_info_s *psk_key_info)
899903
{
900904
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
901905
if (!cur || thread_info(cur) || !cur->mac_parameters || (cur->configure_flags & INTERFACE_BOOTSTRAP_DEFINED) == 0) {
902906
return -1;
903907
}
904908

905909
#ifndef HAVE_6LOWPAN_ND
910+
(void) mode;
911+
(void) sec_level;
912+
(void) psk_key_info;
906913
return -1;
907914
#else
908915
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {

source/libNET/src/socket_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ int8_t socket_close(int8_t sid)
108108
int8_t socket_listen(int8_t socket, uint8_t backlog)
109109
{
110110
#ifdef NO_TCP
111+
(void) socket;
112+
(void) backlog;
111113
return -1;
112114
#else
113115
socket_t *socket_ptr = socket_pointer_get(socket);
@@ -141,6 +143,9 @@ int8_t socket_listen(int8_t socket, uint8_t backlog)
141143
int8_t socket_accept(int8_t listen_socket_id, ns_address_t *addr, void (*passed_fptr)(void *))
142144
{
143145
#ifdef NO_TCP
146+
(void) listen_socket_id;
147+
(void) addr;
148+
(void) passed_fptr;
144149
return -1;
145150
#else
146151
socket_t *socket_ptr = socket_pointer_get(listen_socket_id);
@@ -189,6 +194,8 @@ int8_t socket_accept(int8_t listen_socket_id, ns_address_t *addr, void (*passed_
189194
int8_t socket_shutdown(int8_t socket, uint8_t how)
190195
{
191196
#ifdef NO_TCP
197+
(void) socket;
198+
(void) how;
192199
return -1;
193200
#else
194201
socket_t *socket_ptr = socket_pointer_get(socket);
@@ -608,8 +615,8 @@ int8_t socket_connect(int8_t socket, ns_address_t *address, uint8_t randomly_tak
608615

609616
socket_ptr->flags |= SOCKET_FLAG_CONNECTING;
610617
}
611-
#endif
612618
exit:
619+
#endif
613620
if (status != 0) {
614621
memcpy(inet_pcb->remote_address, ns_in6addr_any, 16);
615622
inet_pcb->remote_port = 0;

0 commit comments

Comments
 (0)