Skip to content

Commit

Permalink
Merge pull request #591 from david-cermak/fix/modem_clang_tidy
Browse files Browse the repository at this point in the history
[modem]: Fixes clang-tidy warnings
  • Loading branch information
david-cermak authored Jun 7, 2024
2 parents 5d69d3f + dabd4bf commit 7f248bd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 13 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/run-host-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ jobs:
shell: bash
if: ${{ inputs.run_coverage }}
run: |
apt-get update && apt-get install -y python3-pip rsync
python -m pip install gcovr
apt-get update && apt-get install -y rsync
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install gcovr
cd $GITHUB_WORKSPACE/${{inputs.component_path}}
component=$(basename ${{ inputs.component_path }})
gcov `find . -name "$component*gcda"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ class CMux {
size_t frame_header_offset;
uint8_t *payload_start;
size_t total_payload_size;
int instance;
int sabm_ack;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Netif {
static void on_ppp_changed(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data);

std::shared_ptr<DTE> ppp_dte;
esp_netif_t *netif;
struct ppp_netif_driver driver {};
SignalGroup signal;
static const size_t PPP_STARTED = SignalGroup::bit0;
Expand Down
5 changes: 4 additions & 1 deletion components/esp_modem/src/esp_modem_cmux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ bool CMux::data_available(uint8_t *data, size_t len)
return false;
}
} else if ((type & FT_UIH) == FT_UIH && dlci == 0) { // notify the internal DISC command
if ((len > 0 && (data[0] & 0xE1) == 0xE1) || (data == nullptr)) {
if ((data == nullptr) || (len > 0 && (data[0] & 0xE1) == 0xE1)) {
// Not a DISC, ignore (MSC frame)
return true;
}
Expand Down Expand Up @@ -346,6 +346,9 @@ bool CMux::on_cmux_data(uint8_t *data, size_t actual_len)
actual_len = term->read(data, buffer.size);
#endif
}
if (data == nullptr) {
return false;
}
ESP_LOG_BUFFER_HEXDUMP("CMUX Received", data, actual_len, ESP_LOG_VERBOSE);
CMuxFrame frame = { .ptr = data, .len = actual_len };
while (frame.len > 0) {
Expand Down
2 changes: 1 addition & 1 deletion components/esp_modem/src/esp_modem_netif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Netif::receive(uint8_t *data, size_t len)
}

Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
ppp_dte(std::move(e)), netif(ppp_netif)
ppp_dte(std::move(e))
{
driver.base.netif = ppp_netif;
driver.ppp = this;
Expand Down
14 changes: 9 additions & 5 deletions components/esp_modem/src/esp_modem_netif_linux.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -29,20 +29,24 @@ esp_err_t Netif::esp_modem_post_attach(esp_netif_t *esp_netif, void *args)

void Netif::receive(uint8_t *data, size_t len)
{
esp_netif_receive(netif, data, len);
esp_netif_receive(driver.base.netif, data, len);
}

Netif::Netif(std::shared_ptr<DTE> e, esp_netif_t *ppp_netif) :
ppp_dte(std::move(e)), netif(ppp_netif) {}
ppp_dte(std::move(e))
{
driver.base.netif = ppp_netif;
driver.ppp = this;
}

void Netif::start()
{
ppp_dte->set_read_cb([this](uint8_t *data, size_t len) -> bool {
receive(data, len);
return true;
});
netif->transmit = esp_modem_dte_transmit;
netif->ctx = (void *)this;
driver.base.netif->transmit = esp_modem_dte_transmit;
driver.base.netif->ctx = (void *)this;
signal.set(PPP_STARTED);
}

Expand Down
2 changes: 1 addition & 1 deletion components/esp_modem/src/esp_modem_term_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ int FdTerminal::write(uint8_t *data, size_t len)

FdTerminal::~FdTerminal()
{
stop();
FdTerminal::stop();
}

} // namespace esp_modem
2 changes: 1 addition & 1 deletion components/esp_modem/src/esp_modem_vfs_uart_creator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "uart_resource.hpp"
#include "vfs_resource/vfs_create.hpp"

constexpr const char *TAG = "vfs_uart_creator";
[[maybe_unused]] constexpr const char *TAG = "vfs_uart_creator";


struct esp_modem_vfs_resource {
Expand Down

0 comments on commit 7f248bd

Please sign in to comment.