Skip to content

Commit 70fa3af

Browse files
committed
fix(modem): Fixed clang-tidy warnings
* private field 'netif' is not used [clang-diagnostic-unused-private-field] * private field 'instance' is not used [clang-diagnostic-unused-private-field] * Call to virtual method 'FdTerminal::stop' during destruction bypasses virtual dispatch [clang-analyzer-optin.cplusplus.VirtualCall] * unused variable 'TAG' [clang-diagnostic-unused-const-variable] * Null pointer passed as 2nd argument to memory copy function [clang-analyzer-unix.cstring.NullArg] * Array access (from variable 'data') results in a null pointer dereference [clang-analyzer-core.NullDereference]
1 parent 5d69d3f commit 70fa3af

File tree

7 files changed

+16
-11
lines changed

7 files changed

+16
-11
lines changed

components/esp_modem/include/cxx_include/esp_modem_cmux.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ class CMux {
142142
size_t frame_header_offset;
143143
uint8_t *payload_start;
144144
size_t total_payload_size;
145-
int instance;
146145
int sabm_ack;
147146

148147
/**

components/esp_modem/include/cxx_include/esp_modem_netif.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class Netif {
6565
static void on_ppp_changed(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);
6666

6767
std::shared_ptr<DTE> ppp_dte;
68-
esp_netif_t *netif;
6968
struct ppp_netif_driver driver {};
7069
SignalGroup signal;
7170
static const size_t PPP_STARTED = SignalGroup::bit0;

components/esp_modem/src/esp_modem_cmux.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ bool CMux::data_available(uint8_t *data, size_t len)
150150
return false;
151151
}
152152
} else if ((type & FT_UIH) == FT_UIH && dlci == 0) { // notify the internal DISC command
153-
if ((len > 0 && (data[0] & 0xE1) == 0xE1) || (data == nullptr)) {
153+
if ((data == nullptr) || (len > 0 && (data[0] & 0xE1) == 0xE1)) {
154154
// Not a DISC, ignore (MSC frame)
155155
return true;
156156
}
@@ -346,6 +346,9 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len)
346346
actual_len = term->read(data, buffer.size);
347347
#endif
348348
}
349+
if (data == nullptr) {
350+
return false;
351+
}
349352
ESP_LOG_BUFFER_HEXDUMP("CMUX Received", data, actual_len, ESP_LOG_VERBOSE);
350353
CMuxFrame frame = { .ptr = data, .len = actual_len };
351354
while (frame.len > 0) {

components/esp_modem/src/esp_modem_netif.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ void Netif::receive(uint8_t *data, size_t len)
6969
}
7070

7171
Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
72-
ppp_dte(std::move(e)), netif(ppp_netif)
72+
ppp_dte(std::move(e))
7373
{
7474
driver.base.netif = ppp_netif;
7575
driver.ppp = this;

components/esp_modem/src/esp_modem_netif_linux.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -29,20 +29,24 @@ esp_err_t Netif::esp_modem_post_attach(esp_netif_t *esp_netif, void *args)
2929

3030
void Netif::receive(uint8_t *data, size_t len)
3131
{
32-
esp_netif_receive(netif, data, len);
32+
esp_netif_receive(driver.base.netif, data, len);
3333
}
3434

3535
Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
36-
ppp_dte(std::move(e)), netif(ppp_netif) {}
36+
ppp_dte(std::move(e))
37+
{
38+
driver.base.netif = ppp_netif;
39+
driver.ppp = this;
40+
}
3741

3842
void Netif::start()
3943
{
4044
ppp_dte->set_read_cb([this](uint8_t *data, size_t len) -> bool {
4145
receive(data, len);
4246
return true;
4347
});
44-
netif->transmit = esp_modem_dte_transmit;
45-
netif->ctx = (void *)this;
48+
driver.base.netif->transmit = esp_modem_dte_transmit;
49+
driver.base.netif->ctx = (void *)this;
4650
signal.set(PPP_STARTED);
4751
}
4852

components/esp_modem/src/esp_modem_term_fs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ int FdTerminal::write(uint8_t *data, size_t len)
155155

156156
FdTerminal::~FdTerminal()
157157
{
158-
stop();
158+
FdTerminal::stop();
159159
}
160160

161161
} // namespace esp_modem

components/esp_modem/src/esp_modem_vfs_uart_creator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "uart_resource.hpp"
1515
#include "vfs_resource/vfs_create.hpp"
1616

17-
constexpr const char *TAG = "vfs_uart_creator";
17+
[[maybe_unused]] constexpr const char *TAG = "vfs_uart_creator";
1818

1919

2020
struct esp_modem_vfs_resource {

0 commit comments

Comments
 (0)