Skip to content

Commit 54ab974

Browse files
author
Teppo Järvelin
committed
Fixed coverity warnings for targets folder. Also fixed one bug while copying sim.
1 parent fa61f09 commit 54ab974

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

features/cellular/easy_cellular/CellularConnectionFSM.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool CellularConnectionFSM::power_on()
136136
void CellularConnectionFSM::set_sim_pin(const char * sim_pin)
137137
{
138138
strncpy(_sim_pin, sim_pin, sizeof(_sim_pin));
139-
_sim_pin[sizeof(_sim_pin)] = '\0';
139+
_sim_pin[sizeof(_sim_pin)-1] = '\0';
140140
}
141141

142142
bool CellularConnectionFSM::open_sim()

features/cellular/framework/AT/AT_CellularNetwork.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ nsapi_error_t AT_CellularNetwork::connect()
310310

311311
nsapi_error_t AT_CellularNetwork::open_data_channel()
312312
{
313+
#if NSAPI_PPP_AVAILABLE
313314
tr_info("Open data channel in PPP mode");
314315
_at.cmd_start("AT+CGDATA=\"PPP\",");
315316
_at.write_int(_cid);
@@ -323,6 +324,9 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
323324
* If blocking: mbed_ppp_init() is a blocking call, it will block until
324325
connected, or timeout after 30 seconds*/
325326
return nsapi_ppp_connect(_at.get_file_handle(), callback(this, &AT_CellularNetwork::ppp_status_cb), NULL, NULL, _ip_stack_type);
327+
#else
328+
return NSAPI_ERROR_OK;
329+
#endif // #if NSAPI_PPP_AVAILABLE
326330
}
327331

328332
/**

features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void QUECTEL_BG96_CellularStack::handle_open_socket_response(int &modem_connect_
9999
}
100100
nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *socket)
101101
{
102-
int modem_connect_id;
102+
int modem_connect_id = -1;
103103
int request_connect_id = socket->id;
104104
int remote_port = 0;
105105
int err = -1;
@@ -246,7 +246,9 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_recvfrom_impl(CellularS
246246
recv_len = _at.read_int();
247247
_at.read_string(ip_address, sizeof(ip_address));
248248
port = _at.read_int();
249-
_at.read_bytes((uint8_t*)buffer, recv_len);
249+
if (recv_len > 0) {
250+
_at.read_bytes((uint8_t*)buffer, recv_len);
251+
}
250252
_at.resp_stop();
251253

252254
if (!recv_len || (_at.get_last_error() != NSAPI_ERROR_OK)) {

0 commit comments

Comments
 (0)