Skip to content

Commit

Permalink
Fix additional warnings (#2849)
Browse files Browse the repository at this point in the history
**Move sanitizers to main build, add BUILD_VARS**

Although asan/ubsan aren't supported for embedded targets,
there do appear to be more extensive compile-time checks which are useful.
Just be nice at the end and don't try to link anything.

**Remove Windows esp32 `dist` directory after installing tools**

Saves 750+MB from cache (per image; 2 images).

**Build with additional warnings in STRICT, and fix most of them**

Switch statements may fall through: use [[falthrough]] for C++.
There isn't yet a standard for C, though `/* fallthrough */` comments seem to work for some compilers (not all).

Unused parameters. Happens for some code when debug isn't enabled - apply [[maybe_unused]] in C++.
  For others remove parameter name (C++ only), unless it's useful/descriptive.
  For C there is no standard, so just using `(void)` cast statement.
  Leave those which might mask other issues, such as code which isn't yet implemented.
  esp-idf has lots of unused parameter warnings; quench those.

Base class X should be explicitly initialized in the copy constructor

Fix 'type qualifiers ignored on function return type'

Fix use of signed/unsigned types


**Remove unused code from `Wire` library**

`I2Cdev` has similar crud but needs far more work. Leave it.

**Fix Graphics library bugs**

Unused parameter warnings highlighted bugs in `Region` and `SolidBrush` classes.
Make Region constructor explicit.



muldivMaxValue parameter 1 never used, not required

**Update scanlog.py**

There are lots of duplicate warnings in logs, so update this tool to de-duplicate and categorise them by source line.

Support scanning logs obtained via github CLI
Integrate GH fetch
Add Job information
Scan warnings, deduplicate and support filtering
Add README
  • Loading branch information
mikee47 authored Jul 2, 2024
1 parent a49290b commit 5b70cc1
Show file tree
Hide file tree
Showing 147 changed files with 1,014 additions and 422 deletions.
5 changes: 4 additions & 1 deletion Sming/Arch/Esp32/Components/driver/hw_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@

#include <driver/hw_timer.h>
#include <driver/periph_ctrl.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <hal/timer_ll.h>
#pragma GCC diagnostic pop
#include <esp_intr_alloc.h>
#include <soc/timer_periph.h>

Expand Down Expand Up @@ -43,7 +46,7 @@ class TimerConfig
#endif
}

void IRAM_ATTR attach_interrupt(hw_timer_source_type_t source_type, hw_timer_callback_t callback, void* arg)
void IRAM_ATTR attach_interrupt(hw_timer_source_type_t, hw_timer_callback_t callback, void* arg)
{
if(isr_handle != nullptr) {
detach_interrupt();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsign-compare"
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include_next <driver/spi_master.h>

Expand Down
2 changes: 1 addition & 1 deletion Sming/Arch/Esp32/Components/driver/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ bool smg_uart_intr_config(smg_uart_t* uart, const smg_uart_intr_config_t* config
return true;
}

void smg_uart_swap(smg_uart_t* uart, int tx_pin)
void smg_uart_swap(smg_uart_t*, int)
{
// Not implemented
}
Expand Down
2 changes: 1 addition & 1 deletion Sming/Arch/Esp32/Components/esp32/src/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bool system_update_cpu_freq(uint32_t freq)
esp_err_t err = esp_pm_get_configuration(&config);
if(err != ESP_OK) {
debug_e("[PM] Failed to read PM config %u", err);
} else if(config.max_freq_mhz == freq) {
} else if((unsigned)config.max_freq_mhz == freq) {
return true;
}

Expand Down
8 changes: 8 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/src/include/esp_event.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include_next <esp_event.h>

#pragma GCC diagnostic pop
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@
#include "esp_tasks.h"
#include <heap.h>
#include <esp_system.h>
#include <os.h>
#include <soc/soc.h>
#include <driver/gpio.h>
#include <driver/adc.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include <os.h>
#include <freertos/FreeRTOS.h>
#include <freertos/portmacro.h>
#pragma GCC diagnostic pop

#include <m_printf.h>
#include <debug_progmem.h>
Expand Down
8 changes: 8 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/src/include/esp_task.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include_next <esp_task.h>

#pragma GCC diagnostic pop
8 changes: 8 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/src/include/esp_task_wdt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include_next <esp_task_wdt.h>

#pragma GCC diagnostic pop
8 changes: 8 additions & 0 deletions Sming/Arch/Esp32/Components/esp32/src/include/hal/gpio_ll.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once

#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"

#include_next <hal/gpio_ll.h>

#pragma GCC diagnostic pop
4 changes: 2 additions & 2 deletions Sming/Arch/Esp32/Components/esp32/src/tasks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ os_task_t taskCallback;

} // namespace

bool system_os_task(os_task_t callback, uint8_t prio, os_event_t* events, uint8_t qlen)
bool system_os_task(os_task_t callback, uint8_t prio, os_event_t*, uint8_t)
{
auto handler = [](void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) {
auto handler = [](void*, esp_event_base_t, int32_t event_id, void* event_data) {
assert(taskCallback != nullptr);

os_event_t ev{os_signal_t(event_id), 0};
Expand Down
6 changes: 0 additions & 6 deletions Sming/Arch/Esp32/Components/gdbstub/gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@ void gdb_detach(void)
{
}



unsigned __gdb_no_op(void)
{
return 0;
}

//#define NOOP __attribute__((weak, alias("__gdb_no_op")))
//
//void gdb_on_attach(bool attached) NOOP;
3 changes: 3 additions & 0 deletions Sming/Arch/Esp32/Services/Profiling/TaskStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
*/

#include <Services/Profiling/TaskStat.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#pragma GCC diagnostic pop
#include <bitset>
#include <cstdlib>

Expand Down
4 changes: 4 additions & 0 deletions Sming/Arch/Esp32/Tools/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ python "%IDF_PATH%\tools\idf_tools.py" --non-interactive install
python -m pip install %SMINGTOOLS%/gevent-1.5.0-cp39-cp39-win_amd64.whl
python3 "%IDF_PATH%\tools\idf_tools.py" --non-interactive install-python-env

if "%CI_BUILD_DIR%" NEQ "" (
del /q "%IDF_TOOLS_PATH%\dist\*"
)

if "%INSTALL_IDF_VER%" == "5.0" goto :install_python
if "%INSTALL_IDF_VER%" == "5.2" goto :install_python
goto :EOF
Expand Down
1 change: 1 addition & 0 deletions Sming/Arch/Esp8266/Components/driver/new-pwm/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ static struct timer_regs* timer = (struct timer_regs*)(0x60000600);
static void IRAM_ATTR
pwm_intr_handler(void* param)
{
(void)param;
if ((pwm_state.current_set[pwm_state.current_phase].off_mask == 0) &&
(pwm_state.current_set[pwm_state.current_phase].on_mask == 0)) {
pwm_state.current_set = pwm_state.next_set;
Expand Down
2 changes: 1 addition & 1 deletion Sming/Arch/Esp8266/Components/driver/uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ void IRAM_ATTR handle_uart_interrupt(uint8_t uart_nr, smg_uart_t* uart)
/** @brief UART interrupt service routine
* @note both UARTS share the same ISR, although UART1 only supports transmit
*/
void IRAM_ATTR uart_isr(void* arg)
void IRAM_ATTR uart_isr(void*)
{
handle_uart_interrupt(UART0, uartInstances[UART0]);
handle_uart_interrupt(UART1, uartInstances[UART1]);
Expand Down
99 changes: 93 additions & 6 deletions Sming/Arch/Esp8266/Components/esp-open-lwip/esp-open-lwip.patch
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ index 1e46ee5..cfc10f8 100644
ipaddr != NULL ? ip4_addr2_16(ipaddr) : 0, \
ipaddr != NULL ? ip4_addr3_16(ipaddr) : 0, \
diff --git a/lwip/app/dhcpserver.c b/lwip/app/dhcpserver.c
index ddb5984..ed8f912 100644
index ddb5984..631bd34 100644
--- a/lwip/app/dhcpserver.c
+++ b/lwip/app/dhcpserver.c
@@ -1,5 +1,5 @@
Expand Down Expand Up @@ -263,7 +263,31 @@ index ddb5984..ed8f912 100644

m->op = DHCP_REPLY;
m->htype = DHCP_HTYPE_ETHERNET;
@@ -485,7 +478,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len)
@@ -325,6 +318,7 @@ static void ICACHE_FLASH_ATTR send_offer(struct dhcps_msg *m)
return;
}
SendOffer_err_t = udp_sendto( pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT );
+ (void)SendOffer_err_t;
#if DHCPS_DEBUG
os_printf("dhcps: send_offer>>udp_sendto result %x\n",SendOffer_err_t);
#endif
@@ -391,6 +385,7 @@ static void ICACHE_FLASH_ATTR send_nak(struct dhcps_msg *m)
return;
}
SendNak_err_t = udp_sendto( pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT );
+ (void)SendNak_err_t;
#if DHCPS_DEBUG
os_printf("dhcps: send_nak>>udp_sendto result %x\n",SendNak_err_t);
#endif
@@ -458,6 +453,7 @@ static void ICACHE_FLASH_ATTR send_ack(struct dhcps_msg *m)
return;
}
SendAck_err_t = udp_sendto( pcb_dhcps, p, &broadcast_dhcps, DHCPS_CLIENT_PORT );
+ (void)SendAck_err_t;
#if DHCPS_DEBUG
os_printf("dhcps: send_ack>>udp_sendto result %x\n",SendAck_err_t);
#endif
@@ -485,7 +481,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len)
bool is_dhcp_parse_end = false;
struct dhcps_state s;

Expand All @@ -272,7 +296,7 @@ index ddb5984..ed8f912 100644

u8_t *end = optptr + len;
u16_t type = 0;
@@ -573,7 +566,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len)
@@ -573,7 +569,7 @@ static uint8_t ICACHE_FLASH_ATTR parse_options(uint8_t *optptr, sint16_t len)
///////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
static sint16_t ICACHE_FLASH_ATTR parse_msg(struct dhcps_msg *m, u16_t len)
Expand All @@ -281,6 +305,25 @@ index ddb5984..ed8f912 100644
if(os_memcmp((char *)m->options,
&magic_cookie,
sizeof(magic_cookie)) == 0){
@@ -744,6 +740,10 @@ static void ICACHE_FLASH_ATTR handle_dhcp(void *arg,
struct ip_addr *addr,
uint16_t port)
{
+ (void)arg;
+ (void)pcb;
+ (void)addr;
+ (void)port;
struct dhcps_msg *pmsg_dhcps = NULL;
sint16_t tlen = 0;
u16_t i = 0;
@@ -1087,7 +1087,6 @@ void ICACHE_FLASH_ATTR dhcps_coarse_tmr(void)
bool ICACHE_FLASH_ATTR wifi_softap_set_dhcps_offer_option(uint8 level, void* optarg)
{
bool offer_flag = true;
- uint8 option = 0;
if (optarg == NULL && wifi_softap_dhcps_status() == false)
return false;

--- a/include/lwip/tcp_impl.h
+++ b/include/lwip/tcp_impl.h
@@ -130,7 +130,7 @@ u32_t tcp_update_rcv_ann_wnd(struct tcp_pcb *pcb)ICACHE_FLASH_ATTR;
Expand Down Expand Up @@ -577,18 +620,35 @@ index 52cd0b0..0ea6ab0 100644
espconn_msg *pdelete_msg = NULL;
struct tcp_pcb *pcb = NULL;
diff --git a/lwip/core/sntp.c b/lwip/core/sntp.c
index 677de93..b645772 100644
index 677de93..73a0dcf 100644
--- a/lwip/core/sntp.c
+++ b/lwip/core/sntp.c
@@ -295,7 +295,6 @@ static ip_addr_t sntp_last_server_address;
@@ -268,7 +268,9 @@ struct sntp_server {
};
static struct sntp_server sntp_servers[SNTP_MAX_SERVERS];

+#if SNTP_GET_SERVERS_FROM_DHCP
static u8_t sntp_set_servers_from_dhcp;
+#endif
#if SNTP_SUPPORT_MULTIPLE_SERVERS
/** The currently used server (initialized to 0) */
static u8_t sntp_current_server;
@@ -295,7 +297,6 @@ static ip_addr_t sntp_last_server_address;
* to compare against in response */
static u32_t sntp_last_timestamp_sent[2];
#endif /* SNTP_CHECK_RESPONSE >= 2 */
-typedef long time_t;
//uint32 current_stamp_1 = 0;
//uint32 current_stamp_2 = 0;
uint32 realtime_stamp = 0;

@@ -361,7 +362,6 @@ sntp_mktm_r(const time_t * tim_p ,struct tm *res ,int is_gmtime)
{
long days, rem;
time_t lcltime;
- int i;
int y;
int yleap;
const int *ip;
diff --git a/include/lwip/sntp.h b/include/lwip/sntp.h
index 14e802e..61d36de 100644
--- a/include/lwip/sntp.h
Expand Down Expand Up @@ -627,3 +687,30 @@ index e2f8e9a..8f4d170 100644
pos += oversize_used;
oversize -= oversize_used;
space -= oversize_used;
diff --git a/include/lwip/debug.h b/include/lwip/debug.h
index d8359ea..344e274 100644
--- a/include/lwip/debug.h
+++ b/include/lwip/debug.h
@@ -62,8 +62,8 @@
#define LWIP_DBG_HALT 0x08U

#ifndef LWIP_NOASSERT
-#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \
- LWIP_PLATFORM_ASSERT(message); } while(0)
+#define LWIP_ASSERT(message, assertion) do { if(!(assertion)) {\
+ LWIP_PLATFORM_ASSERT(message); }} while(0)
#else /* LWIP_NOASSERT */
#define LWIP_ASSERT(message, assertion)
#endif /* LWIP_NOASSERT */
diff --git a/lwip/core/pbuf.c b/lwip/core/pbuf.c
index 6196784..6fd0eb9 100644
--- a/lwip/core/pbuf.c
+++ b/lwip/core/pbuf.c
@@ -103,6 +103,7 @@ static const char mem_debug_file[] ICACHE_RODATA_ATTR = __FILE__;
void ICACHE_FLASH_ATTR
pbuf_free_ooseq_new(void* arg)
{
+ (void)arg;
struct tcp_pcb* pcb;
struct tcp_seg *head = NULL;
struct tcp_seg *seg1 = NULL;
3 changes: 3 additions & 0 deletions Sming/Arch/Esp8266/Components/esp8266/crash_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
extern void __real_system_restart_local();

extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
(void)rst_info;
(void)stack;
(void)stack_end;
}

extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
Expand Down
9 changes: 5 additions & 4 deletions Sming/Arch/Esp8266/Components/gdbstub/appcode/gdb_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ void debug_print_stack(uint32_t start, uint32_t end)
m_puts(instructions);
}

void debug_crash_callback(const rst_info* rst_info, uint32_t stack, uint32_t stack_end)
void debug_crash_callback([[maybe_unused]] const rst_info* rst_info, [[maybe_unused]] uint32_t stack,
[[maybe_unused]] uint32_t stack_end)
{
#ifdef ENABLE_GDB
gdbFlushUserData();
Expand Down Expand Up @@ -226,7 +227,7 @@ void ATTR_GDBINIT gdb_init(void)
#endif
}

void WEAK_ATTR gdb_enable(bool state)
void WEAK_ATTR gdb_enable(bool)
{
}

Expand All @@ -235,7 +236,7 @@ GdbState WEAK_ATTR gdb_present(void)
return eGDB_NotPresent;
}

void WEAK_ATTR gdb_on_attach(bool attached)
void WEAK_ATTR gdb_on_attach(bool)
{
}

Expand All @@ -245,7 +246,7 @@ void WEAK_ATTR gdb_detach(void)

} // extern "C"

int WEAK_ATTR gdb_syscall(const GdbSyscallInfo& info)
int WEAK_ATTR gdb_syscall(const GdbSyscallInfo&)
{
return -1;
}
2 changes: 1 addition & 1 deletion Sming/Arch/Esp8266/Components/gdbstub/gdbuart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static void IRAM_ATTR doCtrlBreak()
}
}

static void IRAM_ATTR gdb_uart_callback(smg_uart_t* uart, uint32_t status)
static void IRAM_ATTR gdb_uart_callback(smg_uart_t*, uint32_t status)
{
#if GDBSTUB_ENABLE_UART2
user_uart_status = status;
Expand Down
4 changes: 2 additions & 2 deletions Sming/Arch/Esp8266/Components/heap/alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ void operator delete[](void* ptr)
free(ptr);
}

void operator delete(void* ptr, size_t sz)
void operator delete(void* ptr, size_t)
{
free(ptr);
}

void operator delete[](void* ptr, size_t sz)
void operator delete[](void* ptr, size_t)
{
free(ptr);
}
Loading

0 comments on commit 5b70cc1

Please sign in to comment.