Skip to content

Commit

Permalink
Fix compiler warnings (ARMmbed#1740)
Browse files Browse the repository at this point in the history
Fix IAR compiler warnings:
-Warning[Pe188]: enumerated type mixed with another type
-Warning[Pe177]: variable "ret" was declared but never referenced

Fix ARM compiler warning:
-warning:  ARMmbed#1295-D: Deprecated declaration thread_router_bootstrap_
                    random_upgrade_jitter - give arg types
-warning:  ARMmbed#68-D: integer conversion resulted in a change of sign
-warning:  ARMmbed#111-D: statement is unreachable

-Do not use multicast address to indicate error.
  • Loading branch information
Arto Kinnunen authored Jul 5, 2018
1 parent 32fe4b8 commit f9b23d4
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 23 deletions.
1 change: 0 additions & 1 deletion source/6LoWPAN/Thread/thread_extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ static void thread_extension_relay_socket_cb(void *cb_res)
uint16_t payload_len;
char *destination_uri_ptr = THREAD_URI_RELAY_RECEIVE;
sckt_data = cb_res;
int ret MAYBE_UNUSED = -1;

protocol_interface_info_entry_t *cur = protocol_stack_interface_info_get_by_id(sckt_data->interface_id);

Expand Down
20 changes: 10 additions & 10 deletions source/6LoWPAN/Thread/thread_router_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ uint16_t thread_router_bootstrap_child_count_get(protocol_interface_info_entry_t
}
mle_neigh_table_list_t *mle_table = mle_class_active_list_get(cur->id);
if (!mle_table) {
return -1;
return 0;
}
ns_list_foreach(mle_neigh_table_entry_t, cur_entry, mle_table) {
if (thread_router_addr_from_addr(cur_entry->short_adr) == router_address) {
Expand All @@ -1230,12 +1230,12 @@ static uint16_t thread_router_bootstrap_child_address_generate(protocol_interfac
{
mle_neigh_table_list_t *mle_table = mle_class_active_list_get(cur->id);
if (!mle_table) {
return -1;
return 0xfffe;
}

if (thread_router_bootstrap_child_count_get(cur) >= cur->thread_info->maxChildCount) {
tr_info("Maximum count %d reached", cur->thread_info->maxChildCount);
return 0xffff;
return 0xfffe;
}

bool address_allocated = false;
Expand All @@ -1254,24 +1254,24 @@ static uint16_t thread_router_bootstrap_child_address_generate(protocol_interfac
}
if (address_allocated){
// all possible addresses already allocated
return 0xffff;
return 0xfffe;
}
return ((mac_helper_mac16_address_get(cur) & THREAD_ROUTER_MASK) | cur->thread_info->lastAllocatedChildAddress);
}

static bool thread_child_id_request(protocol_interface_info_entry_t *cur, mle_neigh_table_entry_t *entry_temp)
{
//Remove All Short address links from router
if (entry_temp->short_adr != 0xffff) {
if (entry_temp->short_adr < 0xfffe) {
protocol_6lowpan_release_short_link_address_from_neighcache(cur, entry_temp->short_adr);
}

//allocate child address if current is router, 0xffff or not our child
//allocate child address if current is router, >0xfffe or not our child
if (!thread_addr_is_child(mac_helper_mac16_address_get(cur), entry_temp->short_adr)) {
entry_temp->short_adr = thread_router_bootstrap_child_address_generate(cur);
}

if (entry_temp->short_adr == 0xffff) {
if (entry_temp->short_adr >= 0xfffe) {
return false;
}

Expand Down Expand Up @@ -1900,9 +1900,9 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *
uint32_t timeout = 0;
uint64_t active_timestamp = 0;
uint64_t pending_timestamp = 0;
mle_tlv_info_t addressRegisterTlv = {0};
mle_tlv_info_t challengeTlv = {0};
mle_tlv_info_t tlv_req = {0};
mle_tlv_info_t addressRegisterTlv = {.tlvType = MLE_TYPE_SRC_ADDRESS};
mle_tlv_info_t challengeTlv = {.tlvType = MLE_TYPE_SRC_ADDRESS};
mle_tlv_info_t tlv_req = {.tlvType = MLE_TYPE_SRC_ADDRESS};
entry_temp = mle_class_get_entry_by_ll64(cur->id, linkMargin, mle_msg->packet_src_address, false, NULL);

if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status)) {
Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/Thread/thread_router_bootstrap.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void thread_router_bootstrap_active_router_attach(struct protocol_interface_info
int thread_router_bootstrap_route_tlv_push(protocol_interface_info_entry_t *cur, uint8_t *route_tlv, uint8_t route_len, uint8_t linkMargin, mle_neigh_table_entry_t *entry);
void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg, struct mle_security_header *security_headers);
void thread_router_bootstrap_timer(protocol_interface_info_entry_t *cur, uint32_t ticks);
uint32_t thread_router_bootstrap_random_upgrade_jitter();
uint32_t thread_router_bootstrap_random_upgrade_jitter(void);
void thread_router_bootstrap_advertiment_analyze(protocol_interface_info_entry_t *cur, uint8_t *src_address, mle_neigh_table_entry_t *entry_temp, uint16_t shortAddress);

void thread_router_bootstrap_multicast_forwarder_enable(protocol_interface_info_entry_t *cur, buffer_t *buf);
Expand Down
6 changes: 3 additions & 3 deletions source/6LoWPAN/Thread/thread_routing.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static inline thread_link_quality_e thread_quality_combine(thread_link_quality_e
/* Return the quality (worse of incoming and outgoing quality) for a neighbour router */
static inline thread_link_quality_e thread_neighbour_router_quality(const thread_router_link_t *neighbour)
{
return thread_quality_combine(neighbour->incoming_quality, neighbour->outgoing_quality);
return thread_quality_combine((thread_link_quality_e) neighbour->incoming_quality, (thread_link_quality_e) neighbour->outgoing_quality);
}


Expand Down Expand Up @@ -690,8 +690,8 @@ int_fast8_t thread_routing_add_link(protocol_interface_info_entry_t *cur,
if (our_quality_to_other_neighbour < QUALITY_10dB) {
continue;
}
thread_link_quality_e neighbours_incoming_quality_to_other_neighbour = (byte & ROUTE_DATA_IN_MASK) >> ROUTE_DATA_IN_SHIFT;
thread_link_quality_e neighbours_outgoing_quality_to_other_neighbour = (byte & ROUTE_DATA_OUT_MASK) >> ROUTE_DATA_OUT_SHIFT;
thread_link_quality_e neighbours_incoming_quality_to_other_neighbour = (thread_link_quality_e) ((byte & ROUTE_DATA_IN_MASK) >> ROUTE_DATA_IN_SHIFT);
thread_link_quality_e neighbours_outgoing_quality_to_other_neighbour = (thread_link_quality_e) ((byte & ROUTE_DATA_OUT_MASK) >> ROUTE_DATA_OUT_SHIFT);
thread_link_quality_e neighbours_quality_to_other_neighbour = thread_quality_combine(neighbours_incoming_quality_to_other_neighbour,
neighbours_outgoing_quality_to_other_neighbour);
if (neighbours_quality_to_other_neighbour < our_quality_to_other_neighbour) {
Expand Down
7 changes: 3 additions & 4 deletions source/MAC/IEEE802_15_4/mac_mcps_sap.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ static int8_t mac_virtual_mlme_nap_req_handler(protocol_interface_rf_mac_setup_s
}

mlme_scan_t mlme_scan_req;
mlme_scan_req.ScanType = *ptr++;
mlme_scan_req.ScanChannels.channel_page = *ptr++;
mlme_scan_req.ScanType = (mac_scan_type_t) *ptr++;
mlme_scan_req.ScanChannels.channel_page = (channel_page_e) *ptr++;
memcpy(mlme_scan_req.ScanChannels.channel_mask, ptr, 32);
ptr += 32;
mlme_scan_req.ScanDuration = *ptr++;
Expand All @@ -239,14 +239,13 @@ static int8_t mac_virtual_mlme_nap_req_handler(protocol_interface_rf_mac_setup_s
memcpy(mlme_scan_req.Key.Keysource, ptr, 8);
mac_mlme_scan_request(&mlme_scan_req, rf_mac_setup);
return 0;
break;
}
case MLME_SET:{
if (mlme_req->ptr_length < 3) {
return -1;
}
mlme_set_t mlme_set_req;
mlme_set_req.attr = *ptr++;
mlme_set_req.attr = (mlme_attr_t) *ptr++;
mlme_set_req.attr_index = *ptr++;
mlme_set_req.value_pointer = ptr;
mlme_set_req.value_size = mlme_req->ptr_length - 2;
Expand Down
2 changes: 1 addition & 1 deletion source/MAC/IEEE802_15_4/mac_mlme.c
Original file line number Diff line number Diff line change
Expand Up @@ -1255,7 +1255,7 @@ int8_t mac_mlme_virtual_confirmation_handle(int8_t driver_id, const uint8_t *dat
if (!mac_setup) {
return -1;
}
mlme_primitive primitive = *data_ptr;
mlme_primitive primitive = (mlme_primitive) *data_ptr;
if (primitive == MLME_SCAN) {
mlme_scan_conf_t *resp = ns_dyn_mem_temporary_alloc(sizeof(mlme_scan_conf_t));
if (!resp) {
Expand Down
2 changes: 1 addition & 1 deletion source/MAC/virtual_rf/virtual_rf_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static int8_t phy_rf_virtual_rx(const uint8_t *data_ptr, uint16_t data_len,int8_
return -1;
}
phy_msg.id = MACTUN_MLME_NAP_EXTENSION;
phy_msg.message.mlme_request.primitive = *data_ptr++;
phy_msg.message.mlme_request.primitive = (mlme_primitive) *data_ptr++;
phy_msg.message.mlme_request.mlme_ptr = data_ptr;
phy_msg.message.mlme_request.ptr_length = (data_len - 2);

Expand Down
2 changes: 1 addition & 1 deletion source/Service_Libs/mdns/ns_fnet_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fnet_socket_t fnet_socket(fnet_address_family_t family, fnet_socket_type_t type,
fnet_return_t fnet_socket_bind( fnet_socket_t s, const struct sockaddr *name, fnet_size_t namelen )
{
(void)namelen;
ns_address_t ns_source_addr = {0};
ns_address_t ns_source_addr;
int8_t socket_id = (int8_t)(long)s;
fnet_return_t fnet_ret_val = FNET_ERR;
const struct sockaddr_in6 *namein6 = (const struct sockaddr_in6 *) name;
Expand Down
2 changes: 1 addition & 1 deletion source/libNET/src/multicast_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int_fast8_t multicast_mpl_set_default_parameters(int8_t interface_id,
uint8_t control_message_k,
uint8_t control_message_timer_expirations)
{
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get(interface_id);
protocol_interface_info_entry_t *interface = protocol_stack_interface_info_get_by_id(interface_id);
if (!interface) {
return -1;
}
Expand Down

0 comments on commit f9b23d4

Please sign in to comment.