Skip to content

Commit

Permalink
Clean ARMC6/GCC compiler warnings (ARMmbed#2278)
Browse files Browse the repository at this point in the history
Clean ARMC6/GCC compiler warnings from all nanostack configurations.
  • Loading branch information
Arto Kinnunen authored Jan 22, 2020
1 parent 807632d commit d5cf8d5
Show file tree
Hide file tree
Showing 18 changed files with 72 additions and 15 deletions.
1 change: 1 addition & 0 deletions source/6LoWPAN/MAC/mac_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ int8_t mac_helper_key_link_frame_counter_set(int8_t interface_id, uint32_t seq_p

void mac_helper_devicetable_remove(mac_api_t *mac_api, uint8_t attribute_index, uint8_t *mac64)
{
(void) mac64;
if (!mac_api) {
return;
}
Expand Down
1 change: 1 addition & 0 deletions source/6LoWPAN/MAC/mac_response_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ void mcps_data_indication_handler(const mac_api_t *api, const mcps_data_ind_t *d
void mcps_purge_confirm_handler(const mac_api_t *api, mcps_purge_conf_t *data)
{
(void)api;
(void)data;
tr_info("MCPS Data Purge confirm status %u, for handle %u", data->status, data->msduHandle);
}

Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/ND/nd_router_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -1754,6 +1754,8 @@ void nd_6lowpan_set_radv_params(protocol_interface_info_entry_t *cur_interface)
cur_interface->adv_retrans_timer = nd_params.ra_retrans_timer;
cur_interface->max_initial_rtr_adv_interval = nd_params.ra_interval_min;
cur_interface->max_initial_rtr_advertisements = nd_params.ra_transmits;
#else
(void) cur_interface;
#endif
}
#endif // HAVE_6LOWPAN_ND
Expand Down
3 changes: 1 addition & 2 deletions source/6LoWPAN/Thread/thread_test_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,11 +643,10 @@ int thread_test_version_set(int8_t interface_id, uint8_t version)

int thread_test_pbbr_response_override_set(int8_t interface_id, uint8_t dua_status, uint8_t dua_count, uint8_t ba_failure_count)
{
#ifdef HAVE_THREAD
#if defined(HAVE_THREAD) && defined(HAVE_THREAD_V2) && defined(HAVE_THREAD_BORDER_ROUTER)
(void)interface_id;
thread_bbr_commercial_status_override_set(dua_status, dua_count, ba_failure_count);
return 0;

#else
(void)interface_id;
(void)dua_status;
Expand Down
4 changes: 2 additions & 2 deletions source/6LoWPAN/ws/ws_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@

#define RPL_INSTANCE_ID 1

static uint8_t current_instance_id = RPL_INSTANCE_ID;

#ifdef HAVE_WS_BORDER_ROUTER

static uint8_t current_instance_id = RPL_INSTANCE_ID;

#define WS_ULA_LIFETIME 24*3600
#define WS_ROUTE_LIFETIME WS_ULA_LIFETIME
#define WS_DHCP_ADDRESS_LIFETIME 2*3600
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_pae_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ void ws_pae_auth_cb_register(protocol_interface_info_entry_t *interface_ptr, ws_
#else

#define ws_pae_auth_init(interface_ptr, gtks, next_gtks, certs, timer_settings) 1
#define ws_pae_auth_timing_adjust(timing) 1
#define ws_pae_auth_timing_adjust(timing)
#define ws_pae_auth_addresses_set(interface_ptr, local_port, remote_addr, remote_port) 1
#define ws_pae_auth_delete NULL
#define ws_pae_auth_cb_register(interface_ptr, hash_set, nw_key_insert, nw_key_index_set) {(void) hash_set;}
Expand Down
10 changes: 8 additions & 2 deletions source/6LoWPAN/ws/ws_pae_nvm_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ nvm_tlv_entry_t *ws_pae_buffer_allocate(void)

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)
{

int len;
tlv_entry->tag = PAE_NVM_NW_INFO_TAG;
tlv_entry->len = PAE_NVM_NW_INFO_LEN;

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

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

for (uint8_t i = 0; i < GTK_NUM; i++) {
Expand Down
3 changes: 3 additions & 0 deletions source/Common_Protocols/icmpv6_radv.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ void icmpv6_stop_router_advertisements(protocol_interface_info_entry_t *cur, con
*/
static void icmpv6_send_ra(protocol_interface_info_entry_t *cur, const uint8_t *dest, const uint8_t *abro)
{
#ifndef HAVE_RPL
(void) abro;
#endif
if (cur->nwk_id == IF_6LoWPAN) {
nd_ra_build_by_abro(abro, dest, cur);
} else {
Expand Down
6 changes: 6 additions & 0 deletions source/Common_Protocols/ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,9 @@ static buffer_t *ipv6_tunnel_exit(buffer_t *buf, uint8_t *payload)
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)
{
(void) nh;
#ifndef HAVE_RPL
(void) ll_src;
#endif
if (payload_length < 2) {
return icmpv6_error(buf, cur, ICMPV6_TYPE_ERROR_PARAMETER_PROBLEM, ICMPV6_CODE_PARAM_PRB_HDR_ERR, 4);
}
Expand Down Expand Up @@ -853,6 +856,9 @@ static buffer_t *ipv6_handle_options(buffer_t *buf, protocol_interface_info_entr

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)
{
#ifndef HAVE_RPL
(void) forward_out;
#endif
if (buf->options.ll_security_bypass_rx) {
tr_warn("Routing header: Security check fail");
protocol_stats_update(STATS_IP_RX_DROP, 1);
Expand Down
8 changes: 6 additions & 2 deletions source/Core/ns_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,14 +287,16 @@ void socket_release(socket_t *socket)
if (tcp_info(socket->inet_pcb)) {
/* This may trigger a reset if pending data. Do it first so you
* get just the reset, rather than a FIN. */
tcp_session_shutdown_read(tcp_info(socket->inet_pcb));
tcp_error sock_status = tcp_session_shutdown_read(tcp_info(socket->inet_pcb));
/* This can also cause TCP deletion */
if (tcp_info(socket->inet_pcb)) {
tcp_session_close(tcp_info(socket->inet_pcb));
sock_status = tcp_session_close(tcp_info(socket->inet_pcb));
}
if (tcp_info(socket->inet_pcb)) {
tcp_socket_released(tcp_info(socket->inet_pcb));
}
// prevent warning "statement with no effect" when TCP is disabled
(void) sock_status;
} else {
/* Unbind the internet control block - ensures users are not prevented
* from binding a new socket to the same port if the socket lingers
Expand Down Expand Up @@ -1362,8 +1364,10 @@ int16_t socket_buffer_sendmsg(int8_t sid, buffer_t *buf, const struct ns_msghdr

protocol_push(buf);

#ifndef NO_TCP
/* TCP jumps back to here */
success:
#endif
if (flags & NS_MSG_LEGACY0) {
return 0;
} else {
Expand Down
1 change: 1 addition & 0 deletions source/MAC/IEEE802_15_4/mac_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ int8_t mac_mlme_set_req(protocol_interface_rf_mac_setup_s *rf_mac_setup, const m
rf_mac_setup->dev_driver->phy_driver->extension(PHY_EXTENSION_SET_RF_CONFIGURATION, (uint8_t *) set_req->value_pointer);
mac_mlme_set_symbol_rate(rf_mac_setup);
phy_rf_channel_configuration_s *config_params = (phy_rf_channel_configuration_s *)set_req->value_pointer;
(void) config_params; // unused variable if traces disabled
tr_info("RF config update:");
tr_info("Frequency(ch0): %"PRIu32"Hz", config_params->channel_0_center_frequency);
tr_info("Channel spacing: %"PRIu32"Hz", config_params->channel_spacing);
Expand Down
1 change: 1 addition & 0 deletions source/Security/TLS/tls_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ uint8_t tls_parse_client_hello(uint8_t *ptr, uint16_t len, sec_suite_t *tls_suit
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8:
thep->client_knows_standard_ecc_ciphersuite = true;
/* no break */
/* fall through */
case TLS_ECDHE_ECDSA_WITH_AES_128_CCM_8_COMPAT:
tr_debug("Client Sup ECC");
ret_val |= SEC_CIPHERSUITE_ECC;
Expand Down
4 changes: 2 additions & 2 deletions source/Security/protocols/key_sec_prot/key_sec_prot.c
Original file line number Diff line number Diff line change
Expand Up @@ -318,10 +318,10 @@ static int8_t key_sec_prot_tx_status_ind(sec_prot_t *prot, sec_prot_tx_status_e

// Indicates TX failure
if (tx_status == SEC_PROT_TX_ERR_TX_NO_ACK) {
sec_prot_result_set(&data->common, KMP_RESULT_ERR_TX_NO_ACK);
sec_prot_result_set(&data->common, SEC_RESULT_ERR_TX_NO_ACK);
} else if (tx_status != SEC_PROT_TX_OK) {
// Indicates other failure
sec_prot_result_set(&data->common, KMP_RESULT_ERR_UNSPEC);
sec_prot_result_set(&data->common, SEC_RESULT_ERR_UNSPEC);
}
prot->state_machine_call(prot);
return 0;
Expand Down
2 changes: 2 additions & 0 deletions source/Service_Libs/fhss/fhss.c
Original file line number Diff line number Diff line change
Expand Up @@ -1385,7 +1385,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: 5 additions & 0 deletions source/libNET/src/net_6lowpan_parameter_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int8_t net_6lowpan_nd_parameter_set(const nd_parameters_s *p)

return 0;
#else
(void) p;
return -2;
#endif
}
Expand All @@ -89,6 +90,8 @@ int8_t net_6lowpan_nd_timer_base_tick_set(uint8_t base_tick_x_100ms)
}

nd_base_tick = base_tick_x_100ms;
#else
(void) base_tick_x_100ms;
#endif
return 0;
}
Expand All @@ -103,5 +106,7 @@ void net_6lowpan_nd_parameter_read(nd_parameters_s *p)
{
#ifdef HAVE_6LOWPAN_ND
*p = nd_params;
#else
(void) p;
#endif
}
16 changes: 14 additions & 2 deletions source/libNET/src/net_load_balance.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,14 @@ int8_t net_load_balance_network_switch_cb_set(int8_t interface_id, net_load_bala

return load_balance_network_switch_cb_set(interface_ptr->lb_api, network_switch_notify);
#else
(void) interface_id;
(void) network_switch_notify;
return -1;
#endif
}


int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon_interval)
int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon_interval)
{
#ifdef HAVE_6LOWPAN_ND
protocol_interface_info_entry_t *interface_ptr = protocol_stack_interface_info_get_by_id(interface_id);
Expand Down Expand Up @@ -188,6 +190,8 @@ int8_t net_load_balance_create(int8_t interface_id, bool enable_periodic_beacon

return 0;
#else
(void) interface_id;
(void) enable_periodic_beacon_interval;
return -1;
#endif
}
Expand All @@ -205,6 +209,7 @@ int8_t net_load_balance_delete(int8_t interface_id)

return load_balance_delete(lb_api);
#else
(void) interface_id;
return -1;
#endif
}
Expand All @@ -223,6 +228,9 @@ int8_t net_load_balance_threshold_set(int8_t interface_id, uint8_t threshold_min

return load_balance_network_threshold_set(interface_ptr->lb_api, threshold_min, threshold_max);
#else
(void) interface_id;
(void) threshold_min;
(void) threshold_max;
return -1;
#endif
}
Expand Down Expand Up @@ -259,8 +267,10 @@ void net_load_balance_internal_state_activate(protocol_interface_info_entry_t *i
set_req.value_pointer = &state;
set_req.value_size = sizeof(bool);
interface_ptr->mac_api->mlme_req(interface_ptr->mac_api, MLME_SET, &set_req);
#else
(void) interface_ptr;
(void) state;
#endif

}

#ifdef HAVE_RPL
Expand Down Expand Up @@ -361,6 +371,8 @@ int8_t net_load_balance_set_max_probability(int8_t interface_id, uint8_t max_p)

return load_balance_set_max_probability(interface_ptr->lb_api, max_p);
#else
(void) interface_id;
(void) max_p;
return -1;
#endif
}
9 changes: 8 additions & 1 deletion source/libNET/src/ns_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@ int8_t arm_nwk_6lowpan_gp_address_mode(int8_t interface_id, net_6lowpan_gp_addre

return 0;
#else
(void) interface_id;
(void) mode;
(void) short_address_base;
(void) define_new_short_address_at_DAD;
return -2;
#endif
}
Expand Down Expand Up @@ -895,14 +899,17 @@ int8_t arm_pana_client_key_pull(int8_t interface_id)
return pana_client_key_pull(interface_id);
}

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)
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)
{
protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(interface_id);
if (!cur || thread_info(cur) || !cur->mac_parameters || (cur->configure_flags & INTERFACE_BOOTSTRAP_DEFINED) == 0) {
return -1;
}

#ifndef HAVE_6LOWPAN_ND
(void) mode;
(void) sec_level;
(void) psk_key_info;
return -1;
#else
if (cur->lowpan_info & INTERFACE_NWK_ACTIVE) {
Expand Down
9 changes: 8 additions & 1 deletion source/libNET/src/socket_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ int8_t socket_close(int8_t sid)
int8_t socket_listen(int8_t socket, uint8_t backlog)
{
#ifdef NO_TCP
(void) socket;
(void) backlog;
return -1;
#else
socket_t *socket_ptr = socket_pointer_get(socket);
Expand Down Expand Up @@ -141,6 +143,9 @@ int8_t socket_listen(int8_t socket, uint8_t backlog)
int8_t socket_accept(int8_t listen_socket_id, ns_address_t *addr, void (*passed_fptr)(void *))
{
#ifdef NO_TCP
(void) listen_socket_id;
(void) addr;
(void) passed_fptr;
return -1;
#else
socket_t *socket_ptr = socket_pointer_get(listen_socket_id);
Expand Down Expand Up @@ -189,6 +194,8 @@ int8_t socket_accept(int8_t listen_socket_id, ns_address_t *addr, void (*passed_
int8_t socket_shutdown(int8_t socket, uint8_t how)
{
#ifdef NO_TCP
(void) socket;
(void) how;
return -1;
#else
socket_t *socket_ptr = socket_pointer_get(socket);
Expand Down Expand Up @@ -608,8 +615,8 @@ int8_t socket_connect(int8_t socket, ns_address_t *address, uint8_t randomly_tak

socket_ptr->flags |= SOCKET_FLAG_CONNECTING;
}
#endif
exit:
#endif
if (status != 0) {
memcpy(inet_pcb->remote_address, ns_in6addr_any, 16);
inet_pcb->remote_port = 0;
Expand Down

0 comments on commit d5cf8d5

Please sign in to comment.