Merge pull request #13476 from talorion/bugfix/fix-warnings

Fix trivial compiler Warnings
pull/13546/head
Martin Kojtal 2020-09-07 09:58:41 +01:00 committed by GitHub
commit b2ac60924c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 33 additions and 27 deletions

View File

@ -107,7 +107,7 @@ void CellularContext::validate_ip_address()
CellularContext::pdp_type_t CellularContext::string_to_pdp_type(const char *pdp_type_str) CellularContext::pdp_type_t CellularContext::string_to_pdp_type(const char *pdp_type_str)
{ {
pdp_type_t pdp_type = DEFAULT_PDP_TYPE; pdp_type_t pdp_type = DEFAULT_PDP_TYPE;
int len = strlen(pdp_type_str); size_t len = strlen(pdp_type_str);
if (len == 6 && memcmp(pdp_type_str, "IPV4V6", len) == 0) { if (len == 6 && memcmp(pdp_type_str, "IPV4V6", len) == 0) {
pdp_type = IPV4V6_PDP_TYPE; pdp_type = IPV4V6_PDP_TYPE;

View File

@ -307,7 +307,7 @@ void CellularStateMachine::retry_state_or_fail()
void CellularStateMachine::state_init() void CellularStateMachine::state_init()
{ {
change_timeout(_state_timeout_power_on); change_timeout(_state_timeout_power_on);
tr_info("Start connecting (timeout %d ms)", _state_timeout_power_on); tr_info("Start connecting (timeout %d ms)", _state_timeout_power_on.count());
_cb_data.error = _cellularDevice.is_ready(); _cb_data.error = _cellularDevice.is_ready();
_status = _cb_data.error ? 0 : DEVICE_READY; _status = _cb_data.error ? 0 : DEVICE_READY;
if (_cb_data.error != NSAPI_ERROR_OK) { if (_cb_data.error != NSAPI_ERROR_OK) {
@ -324,7 +324,7 @@ void CellularStateMachine::state_init()
void CellularStateMachine::state_power_on() void CellularStateMachine::state_power_on()
{ {
change_timeout(_state_timeout_power_on); change_timeout(_state_timeout_power_on);
tr_info("Modem power ON (timeout %d ms)", _state_timeout_power_on); tr_info("Modem power ON (timeout %d ms)", _state_timeout_power_on.count());
if (power_on()) { if (power_on()) {
enter_to_state(STATE_DEVICE_READY); enter_to_state(STATE_DEVICE_READY);
} else { } else {
@ -408,7 +408,7 @@ void CellularStateMachine::state_device_ready()
void CellularStateMachine::state_sim_pin() void CellularStateMachine::state_sim_pin()
{ {
change_timeout(_state_timeout_sim_pin); change_timeout(_state_timeout_sim_pin);
tr_info("Setup SIM (timeout %d ms)", _state_timeout_sim_pin); tr_info("Setup SIM (timeout %d ms)", _state_timeout_sim_pin.count());
if (open_sim()) { if (open_sim()) {
bool success = false; bool success = false;
for (int type = 0; type < CellularNetwork::C_MAX; type++) { for (int type = 0; type < CellularNetwork::C_MAX; type++) {
@ -473,7 +473,7 @@ void CellularStateMachine::state_registering()
// we are already registered, go to attach // we are already registered, go to attach
enter_to_state(STATE_ATTACHING_NETWORK); enter_to_state(STATE_ATTACHING_NETWORK);
} else { } else {
tr_info("Network registration (timeout %d ms)", _state_timeout_registration); tr_info("Network registration (timeout %d ms)", _state_timeout_registration.count());
change_timeout(_state_timeout_registration); change_timeout(_state_timeout_registration);
if (!_command_success && !_plmn) { // don't call set_registration twice for manual registration if (!_command_success && !_plmn) { // don't call set_registration twice for manual registration
_cb_data.error = _network.set_registration(_plmn); _cb_data.error = _network.set_registration(_plmn);
@ -487,7 +487,7 @@ void CellularStateMachine::state_attaching()
{ {
if (_status != ATTACHED_TO_NETWORK) { if (_status != ATTACHED_TO_NETWORK) {
change_timeout(_state_timeout_connect); change_timeout(_state_timeout_connect);
tr_info("Attaching network (timeout %d ms)", _state_timeout_connect); tr_info("Attaching network (timeout %d ms)", _state_timeout_connect.count());
_cb_data.error = _network.set_attach(); _cb_data.error = _network.set_attach();
} }
if (_cb_data.error == NSAPI_ERROR_OK) { if (_cb_data.error == NSAPI_ERROR_OK) {
@ -635,7 +635,7 @@ void CellularStateMachine::event()
tr_debug("%s => %s", get_state_string((CellularStateMachine::CellularState)_state), tr_debug("%s => %s", get_state_string((CellularStateMachine::CellularState)_state),
get_state_string((CellularStateMachine::CellularState)_next_state)); get_state_string((CellularStateMachine::CellularState)_next_state));
} else { } else {
tr_info("Continue after %d seconds", _event_timeout); tr_info("Continue after %d seconds", _event_timeout.count());
} }
_state = _next_state; _state = _next_state;
if (_event_timeout == -1s) { if (_event_timeout == -1s) {

View File

@ -225,8 +225,13 @@ retry_send:
// check for network congestion // check for network congestion
device_err_t err = _at.get_last_device_error(); device_err_t err = _at.get_last_device_error();
if (err.errType == DeviceErrorTypeErrorCME && if (
(err.errCode == AT_UART_BUFFER_ERROR || err.errCode == AT_BACK_OFF_TIMER) || err.errCode == AT_UPLINK_BUSY) { (
err.errType == DeviceErrorTypeErrorCME
&& (err.errCode == AT_UART_BUFFER_ERROR || err.errCode == AT_BACK_OFF_TIMER)
)
|| err.errCode == AT_UPLINK_BUSY
) {
if (socket->proto == NSAPI_UDP) { if (socket->proto == NSAPI_UDP) {
if (retry < 3) { if (retry < 3) {
retry++; retry++;

View File

@ -21,9 +21,13 @@
#include "CellularLog.h" #include "CellularLog.h"
#include "netsocket/TLSSocket.h" #include "netsocket/TLSSocket.h"
static const int sslctxID = 1;
using namespace mbed; using namespace mbed;
using namespace std::chrono_literals;
constexpr int sslctxID = 1;
constexpr auto socket_timeout = 1s;
TELIT_ME310_CellularStack::TELIT_ME310_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) : TELIT_ME310_CellularStack::TELIT_ME310_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
AT_CellularStack(atHandler, cid, stack_type, device) AT_CellularStack(atHandler, cid, stack_type, device)
@ -66,7 +70,6 @@ nsapi_error_t TELIT_ME310_CellularStack::socket_connect(nsapi_socket_t handle, c
activate_ipeasy_context(_cid); activate_ipeasy_context(_cid);
} }
int modem_connect_id = -1;
int err = NSAPI_ERROR_NO_CONNECTION; int err = NSAPI_ERROR_NO_CONNECTION;
int request_connect_id = find_socket_index(socket); int request_connect_id = find_socket_index(socket);
@ -224,9 +227,7 @@ nsapi_error_t TELIT_ME310_CellularStack::deactivate_ipeasy_context(int context_i
nsapi_error_t TELIT_ME310_CellularStack::create_socket_impl(CellularSocket *socket) nsapi_error_t TELIT_ME310_CellularStack::create_socket_impl(CellularSocket *socket)
{ {
int modem_connect_id = -1;
int remote_port = 1; int remote_port = 1;
int err = -1;
if (!is_ipeasy_context_activated(_cid)) { if (!is_ipeasy_context_activated(_cid)) {
tr_debug("IPEasy context not active for %d", _cid); tr_debug("IPEasy context not active for %d", _cid);
@ -399,7 +400,6 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
} }
if (socket->proto == NSAPI_UDP) { if (socket->proto == NSAPI_UDP) {
int data_left = -1;
// UDP has remote_IP and remote_port parameters // UDP has remote_IP and remote_port parameters
_at.read_string(ip_address, sizeof(ip_address)); _at.read_string(ip_address, sizeof(ip_address));
port = _at.read_int(); port = _at.read_int();
@ -408,7 +408,7 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
_at.skip_param(); _at.skip_param();
srecv_size = _at.read_int(); srecv_size = _at.read_int();
data_left = _at.read_int(); _at.read_int();
if (srecv_size > size) { if (srecv_size > size) {
srecv_size = size; srecv_size = size;
} }
@ -440,7 +440,7 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
// read() should not fail // read() should not fail
success = false; success = false;
} }
} else if (timer.read_ms() < ME310_SOCKET_TIMEOUT) { } else if (timer.elapsed_time() < socket_timeout) {
// Wait for URCs // Wait for URCs
_at.process_oob(); _at.process_oob();
} else { } else {
@ -643,4 +643,4 @@ nsapi_error_t TELIT_ME310_CellularStack::setsockopt(nsapi_socket_t handle, int l
return ret; return ret;
} }
#endif #endif

View File

@ -34,7 +34,6 @@ namespace mbed {
#define ME310_SOCKET_BIND_FAIL 556 #define ME310_SOCKET_BIND_FAIL 556
#define ME310_IPEASY_ACTIVATED_CONTEXT 1 #define ME310_IPEASY_ACTIVATED_CONTEXT 1
#define ME310_IPEASY_DEACTIVATED_CONTEXT 0 #define ME310_IPEASY_DEACTIVATED_CONTEXT 0
#define ME310_SOCKET_TIMEOUT 1000
#define CTRL_Z "\x1a" #define CTRL_Z "\x1a"
#define ESC "\x1b" #define ESC "\x1b"

View File

@ -169,7 +169,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
MBED_ASSERT(socket->id != -1); MBED_ASSERT(socket->id != -1);
int sent_len = 0; int sent_len = 0;
uint8_t ch = 0;
if (socket->proto == NSAPI_UDP) { if (socket->proto == NSAPI_UDP) {
if (size > UBLOX_MAX_PACKET_SIZE) { if (size > UBLOX_MAX_PACKET_SIZE) {
@ -372,7 +371,7 @@ UBLOX_AT_CellularStack::CellularSocket *UBLOX_AT_CellularStack::find_socket(int
{ {
CellularSocket *socket = NULL; CellularSocket *socket = NULL;
for (unsigned int x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) { for (ptrdiff_t x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
if (_socket) { if (_socket) {
if (_socket[x]->id == id) { if (_socket[x]->id == id) {
socket = (_socket[x]); socket = (_socket[x]);

View File

@ -60,7 +60,9 @@ extern "C" { // "pppos.h" is missing extern C
/* Timeout to wait for PPP connection to be terminated /* Timeout to wait for PPP connection to be terminated
* (LCP Terminate-Request is answered with Terminate-Ack) * (LCP Terminate-Request is answered with Terminate-Ack)
*/ */
#define PPP_TERMINATION_TIMEOUT 30000 using namespace std::chrono_literals;
constexpr auto PPP_TERMINATION_TIMEOUT = 30s;
// If both IPCP and IPCP6 are made, how long to wait for both to complete // If both IPCP and IPCP6 are made, how long to wait for both to complete
#define PPP_IPCP_IPCP6_DELAY 5000 #define PPP_IPCP_IPCP6_DELAY 5000
@ -655,4 +657,3 @@ MBED_WEAK PPP &PPP::get_default_instance()
*/ */
/* --------------------------------- End Of File ------------------------------ */ /* --------------------------------- End Of File ------------------------------ */

View File

@ -517,7 +517,8 @@ extern "C" {
} }
void *cb_ptr = reinterpret_cast<void *>(ppp_service_sys_timeout_id); void *cb_ptr = reinterpret_cast<void *>(ppp_service_sys_timeout_id);
int unique_id = ppp_service_ptr->event_queue_get()->call_in(msecs, mbed::callback(ppp_sys_timeout_callback, cb_ptr)); auto duration = std::chrono::milliseconds(msecs);
int unique_id = ppp_service_ptr->event_queue_get()->call_in(duration, mbed::callback(ppp_sys_timeout_callback, cb_ptr));
if (unique_id == 0) { if (unique_id == 0) {
tr_error("No free memory for timeout equeue"); tr_error("No free memory for timeout equeue");
ppp_service_if_mutex->unlock(); ppp_service_if_mutex->unlock();

View File

@ -82,7 +82,7 @@ void tcp_test_drop_reset()
} }
#endif #endif
#ifdef FEA_TRACE_SUPPORT #if defined(FEA_TRACE_SUPPORT) && MBED_CONF_MBED_TRACE_ENABLE && (MBED_TRACE_MAX_LEVEL >= TRACE_LEVEL_DEBUG)
static const char *trace_tcp_flags(uint16_t flags) static const char *trace_tcp_flags(uint16_t flags)
{ {
static char buf[9]; static char buf[9];

View File

@ -489,11 +489,12 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
nsapi_addr *tmp = new (std::nothrow) nsapi_addr_t [MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT]; nsapi_addr *tmp = new (std::nothrow) nsapi_addr_t [MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT];
int cached = nsapi_dns_cache_find(host, version, tmp); int cached = nsapi_dns_cache_find(host, version, tmp);
if (cached > 0) { if (cached > 0) {
for (int i = 0; i < MIN(cached, addr_count); i++) { unsigned int us_cached = cached;
for (unsigned int i = 0; i < MIN(us_cached, addr_count); i++) {
addr[i] = tmp[i]; addr[i] = tmp[i];
} }
delete [] tmp; delete [] tmp;
return MIN(cached, addr_count); return MIN(us_cached, addr_count);
} }
delete [] tmp; delete [] tmp;
// create a udp socket // create a udp socket

View File

@ -412,7 +412,7 @@ int sfdp_iterate_next_largest_erase_type(uint8_t &bitfield,
largest_erase_type = idx; largest_erase_type = idx;
if ((size > (int)(smptbl.erase_type_size_arr[largest_erase_type])) && if ((size > (int)(smptbl.erase_type_size_arr[largest_erase_type])) &&
((smptbl.region_high_boundary[region] - offset) ((smptbl.region_high_boundary[region] - offset)
> (int)(smptbl.erase_type_size_arr[largest_erase_type]))) { > (uint64_t)(smptbl.erase_type_size_arr[largest_erase_type]))) {
break; break;
} else { } else {
bitfield &= ~type_mask; bitfield &= ~type_mask;