Skip to content

Commit b2ac609

Browse files
authored
Merge pull request ARMmbed#13476 from talorion/bugfix/fix-warnings
Fix trivial compiler Warnings
2 parents 1778c6d + c4b93fe commit b2ac609

File tree

11 files changed

+33
-27
lines changed

11 files changed

+33
-27
lines changed

connectivity/cellular/source/framework/device/CellularContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void CellularContext::validate_ip_address()
107107
CellularContext::pdp_type_t CellularContext::string_to_pdp_type(const char *pdp_type_str)
108108
{
109109
pdp_type_t pdp_type = DEFAULT_PDP_TYPE;
110-
int len = strlen(pdp_type_str);
110+
size_t len = strlen(pdp_type_str);
111111

112112
if (len == 6 && memcmp(pdp_type_str, "IPV4V6", len) == 0) {
113113
pdp_type = IPV4V6_PDP_TYPE;

connectivity/cellular/source/framework/device/CellularStateMachine.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ void CellularStateMachine::retry_state_or_fail()
307307
void CellularStateMachine::state_init()
308308
{
309309
change_timeout(_state_timeout_power_on);
310-
tr_info("Start connecting (timeout %d ms)", _state_timeout_power_on);
310+
tr_info("Start connecting (timeout %d ms)", _state_timeout_power_on.count());
311311
_cb_data.error = _cellularDevice.is_ready();
312312
_status = _cb_data.error ? 0 : DEVICE_READY;
313313
if (_cb_data.error != NSAPI_ERROR_OK) {
@@ -324,7 +324,7 @@ void CellularStateMachine::state_init()
324324
void CellularStateMachine::state_power_on()
325325
{
326326
change_timeout(_state_timeout_power_on);
327-
tr_info("Modem power ON (timeout %d ms)", _state_timeout_power_on);
327+
tr_info("Modem power ON (timeout %d ms)", _state_timeout_power_on.count());
328328
if (power_on()) {
329329
enter_to_state(STATE_DEVICE_READY);
330330
} else {
@@ -408,7 +408,7 @@ void CellularStateMachine::state_device_ready()
408408
void CellularStateMachine::state_sim_pin()
409409
{
410410
change_timeout(_state_timeout_sim_pin);
411-
tr_info("Setup SIM (timeout %d ms)", _state_timeout_sim_pin);
411+
tr_info("Setup SIM (timeout %d ms)", _state_timeout_sim_pin.count());
412412
if (open_sim()) {
413413
bool success = false;
414414
for (int type = 0; type < CellularNetwork::C_MAX; type++) {
@@ -473,7 +473,7 @@ void CellularStateMachine::state_registering()
473473
// we are already registered, go to attach
474474
enter_to_state(STATE_ATTACHING_NETWORK);
475475
} else {
476-
tr_info("Network registration (timeout %d ms)", _state_timeout_registration);
476+
tr_info("Network registration (timeout %d ms)", _state_timeout_registration.count());
477477
change_timeout(_state_timeout_registration);
478478
if (!_command_success && !_plmn) { // don't call set_registration twice for manual registration
479479
_cb_data.error = _network.set_registration(_plmn);
@@ -487,7 +487,7 @@ void CellularStateMachine::state_attaching()
487487
{
488488
if (_status != ATTACHED_TO_NETWORK) {
489489
change_timeout(_state_timeout_connect);
490-
tr_info("Attaching network (timeout %d ms)", _state_timeout_connect);
490+
tr_info("Attaching network (timeout %d ms)", _state_timeout_connect.count());
491491
_cb_data.error = _network.set_attach();
492492
}
493493
if (_cb_data.error == NSAPI_ERROR_OK) {
@@ -635,7 +635,7 @@ void CellularStateMachine::event()
635635
tr_debug("%s => %s", get_state_string((CellularStateMachine::CellularState)_state),
636636
get_state_string((CellularStateMachine::CellularState)_next_state));
637637
} else {
638-
tr_info("Continue after %d seconds", _event_timeout);
638+
tr_info("Continue after %d seconds", _event_timeout.count());
639639
}
640640
_state = _next_state;
641641
if (_event_timeout == -1s) {

connectivity/drivers/cellular/QUECTEL/BC95/QUECTEL_BC95_CellularStack.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,13 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
225225

226226
// check for network congestion
227227
device_err_t err = _at.get_last_device_error();
228-
if (err.errType == DeviceErrorTypeErrorCME &&
229-
(err.errCode == AT_UART_BUFFER_ERROR || err.errCode == AT_BACK_OFF_TIMER) || err.errCode == AT_UPLINK_BUSY) {
228+
if (
229+
(
230+
err.errType == DeviceErrorTypeErrorCME
231+
&& (err.errCode == AT_UART_BUFFER_ERROR || err.errCode == AT_BACK_OFF_TIMER)
232+
)
233+
|| err.errCode == AT_UPLINK_BUSY
234+
) {
230235
if (socket->proto == NSAPI_UDP) {
231236
if (retry < 3) {
232237
retry++;

connectivity/drivers/cellular/TELIT/ME310/TELIT_ME310_CellularStack.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@
2121
#include "CellularLog.h"
2222
#include "netsocket/TLSSocket.h"
2323

24-
static const int sslctxID = 1;
2524

2625
using namespace mbed;
26+
using namespace std::chrono_literals;
27+
28+
constexpr int sslctxID = 1;
29+
constexpr auto socket_timeout = 1s;
30+
2731

2832
TELIT_ME310_CellularStack::TELIT_ME310_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type, AT_CellularDevice &device) :
2933
AT_CellularStack(atHandler, cid, stack_type, device)
@@ -66,7 +70,6 @@ nsapi_error_t TELIT_ME310_CellularStack::socket_connect(nsapi_socket_t handle, c
6670
activate_ipeasy_context(_cid);
6771
}
6872

69-
int modem_connect_id = -1;
7073
int err = NSAPI_ERROR_NO_CONNECTION;
7174

7275
int request_connect_id = find_socket_index(socket);
@@ -224,9 +227,7 @@ nsapi_error_t TELIT_ME310_CellularStack::deactivate_ipeasy_context(int context_i
224227

225228
nsapi_error_t TELIT_ME310_CellularStack::create_socket_impl(CellularSocket *socket)
226229
{
227-
int modem_connect_id = -1;
228230
int remote_port = 1;
229-
int err = -1;
230231

231232
if (!is_ipeasy_context_activated(_cid)) {
232233
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
399400
}
400401

401402
if (socket->proto == NSAPI_UDP) {
402-
int data_left = -1;
403403
// UDP has remote_IP and remote_port parameters
404404
_at.read_string(ip_address, sizeof(ip_address));
405405
port = _at.read_int();
@@ -408,7 +408,7 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
408408
_at.skip_param();
409409

410410
srecv_size = _at.read_int();
411-
data_left = _at.read_int();
411+
_at.read_int();
412412
if (srecv_size > size) {
413413
srecv_size = size;
414414
}
@@ -440,7 +440,7 @@ nsapi_size_or_error_t TELIT_ME310_CellularStack::socket_recvfrom_impl(CellularSo
440440
// read() should not fail
441441
success = false;
442442
}
443-
} else if (timer.read_ms() < ME310_SOCKET_TIMEOUT) {
443+
} else if (timer.elapsed_time() < socket_timeout) {
444444
// Wait for URCs
445445
_at.process_oob();
446446
} else {
@@ -643,4 +643,4 @@ nsapi_error_t TELIT_ME310_CellularStack::setsockopt(nsapi_socket_t handle, int l
643643

644644
return ret;
645645
}
646-
#endif
646+
#endif

connectivity/drivers/cellular/TELIT/ME310/TELIT_ME310_CellularStack.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ namespace mbed {
3434
#define ME310_SOCKET_BIND_FAIL 556
3535
#define ME310_IPEASY_ACTIVATED_CONTEXT 1
3636
#define ME310_IPEASY_DEACTIVATED_CONTEXT 0
37-
#define ME310_SOCKET_TIMEOUT 1000
3837
#define CTRL_Z "\x1a"
3938
#define ESC "\x1b"
4039

connectivity/drivers/cellular/UBLOX/AT/UBLOX_AT_CellularStack.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
169169
MBED_ASSERT(socket->id != -1);
170170

171171
int sent_len = 0;
172-
uint8_t ch = 0;
173172

174173
if (socket->proto == NSAPI_UDP) {
175174
if (size > UBLOX_MAX_PACKET_SIZE) {
@@ -372,7 +371,7 @@ UBLOX_AT_CellularStack::CellularSocket *UBLOX_AT_CellularStack::find_socket(int
372371
{
373372
CellularSocket *socket = NULL;
374373

375-
for (unsigned int x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
374+
for (ptrdiff_t x = 0; (socket == NULL) && (x < _device.get_property(AT_CellularDevice::PROPERTY_SOCKET_COUNT)); x++) {
376375
if (_socket) {
377376
if (_socket[x]->id == id) {
378377
socket = (_socket[x]);

connectivity/libraries/ppp/source/ppp_service.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ extern "C" { // "pppos.h" is missing extern C
6060
/* Timeout to wait for PPP connection to be terminated
6161
* (LCP Terminate-Request is answered with Terminate-Ack)
6262
*/
63-
#define PPP_TERMINATION_TIMEOUT 30000
63+
using namespace std::chrono_literals;
64+
constexpr auto PPP_TERMINATION_TIMEOUT = 30s;
65+
6466

6567
// If both IPCP and IPCP6 are made, how long to wait for both to complete
6668
#define PPP_IPCP_IPCP6_DELAY 5000
@@ -655,4 +657,3 @@ MBED_WEAK PPP &PPP::get_default_instance()
655657
*/
656658

657659
/* --------------------------------- End Of File ------------------------------ */
658-

connectivity/libraries/ppp/source/ppp_service_if.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,8 @@ extern "C" {
517517
}
518518

519519
void *cb_ptr = reinterpret_cast<void *>(ppp_service_sys_timeout_id);
520-
int unique_id = ppp_service_ptr->event_queue_get()->call_in(msecs, mbed::callback(ppp_sys_timeout_callback, cb_ptr));
520+
auto duration = std::chrono::milliseconds(msecs);
521+
int unique_id = ppp_service_ptr->event_queue_get()->call_in(duration, mbed::callback(ppp_sys_timeout_callback, cb_ptr));
521522
if (unique_id == 0) {
522523
tr_error("No free memory for timeout equeue");
523524
ppp_service_if_mutex->unlock();

connectivity/nanostack/sal-stack-nanostack/source/Common_Protocols/tcp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ void tcp_test_drop_reset()
8282
}
8383
#endif
8484

85-
#ifdef FEA_TRACE_SUPPORT
85+
#if defined(FEA_TRACE_SUPPORT) && MBED_CONF_MBED_TRACE_ENABLE && (MBED_TRACE_MAX_LEVEL >= TRACE_LEVEL_DEBUG)
8686
static const char *trace_tcp_flags(uint16_t flags)
8787
{
8888
static char buf[9];

connectivity/netsocket/source/nsapi_dns.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,11 +489,12 @@ static nsapi_size_or_error_t nsapi_dns_query_multiple(NetworkStack *stack, const
489489
nsapi_addr *tmp = new (std::nothrow) nsapi_addr_t [MBED_CONF_NSAPI_DNS_ADDRESSES_LIMIT];
490490
int cached = nsapi_dns_cache_find(host, version, tmp);
491491
if (cached > 0) {
492-
for (int i = 0; i < MIN(cached, addr_count); i++) {
492+
unsigned int us_cached = cached;
493+
for (unsigned int i = 0; i < MIN(us_cached, addr_count); i++) {
493494
addr[i] = tmp[i];
494495
}
495496
delete [] tmp;
496-
return MIN(cached, addr_count);
497+
return MIN(us_cached, addr_count);
497498
}
498499
delete [] tmp;
499500
// create a udp socket

drivers/source/SFDP.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ int sfdp_iterate_next_largest_erase_type(uint8_t &bitfield,
412412
largest_erase_type = idx;
413413
if ((size > (int)(smptbl.erase_type_size_arr[largest_erase_type])) &&
414414
((smptbl.region_high_boundary[region] - offset)
415-
> (int)(smptbl.erase_type_size_arr[largest_erase_type]))) {
415+
> (uint64_t)(smptbl.erase_type_size_arr[largest_erase_type]))) {
416416
break;
417417
} else {
418418
bitfield &= ~type_mask;

0 commit comments

Comments
 (0)