Skip to content

Commit

Permalink
Merge branch 'feature/gcc-fanalyzer' into 'master'
Browse files Browse the repository at this point in the history
feat(ci): add gnu static analyzer job

See merge request espressif/esp-idf!30902
  • Loading branch information
Lapshin committed Jun 19, 2024
2 parents ec9c941 + ed6e497 commit b0ba568
Show file tree
Hide file tree
Showing 57 changed files with 307 additions and 59 deletions.
16 changes: 16 additions & 0 deletions .gitlab/ci/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ fast_template_app:
BUILD_COMMAND_ARGS: "-p"
#------------------------------------------------------------------------------

#######################
# gnu_static_analyzer #
#######################
gcc_static_analyzer:
extends:
- .build_template_app_template
- .rules:build:target_test
stage: pre_check
tags: [build, shiny]
variables:
CI_CCACHE_DISABLE: 1
ANALYZING_APP: "examples/get-started/hello_world"
script:
- echo "CONFIG_COMPILER_STATIC_ANALYZER=y" >> ${ANALYZING_APP}/sdkconfig.defaults
- python -m idf_build_apps build -vv -p ${ANALYZING_APP} -t all

########################################
# Clang Build Apps Without Tests Cases #
########################################
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
list(APPEND compile_options "-Wno-pointer-bool-conversion")
# mbedTLS md5.c triggers this warning in md5_test_buf (false positive)
list(APPEND compile_options "-Wno-string-concatenation")
# multiple cases of implict convertions between unrelated enum types
# multiple cases of implicit conversions between unrelated enum types
list(APPEND compile_options "-Wno-enum-conversion")
# When IRAM_ATTR is specified both in function declaration and definition,
# it produces different section names, since section names include __COUNTER__.
Expand Down Expand Up @@ -203,8 +203,10 @@ endif()

# GCC-specific options
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
list(APPEND compile_options "-fstrict-volatile-bitfields"
)
list(APPEND compile_options "-fstrict-volatile-bitfields")
if(CONFIG_COMPILER_STATIC_ANALYZER)
list(APPEND compile_options "-fanalyzer")
endif()
endif()

if(CONFIG_ESP_SYSTEM_USE_EH_FRAME)
Expand Down
11 changes: 11 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ mainmenu "Espressif IoT Development Framework Configuration"
bool
default "y" if IDF_TOOLCHAIN="clang"

config IDF_TOOLCHAIN_GCC
bool
default "y" if IDF_TOOLCHAIN="gcc"

config IDF_TARGET_ARCH_RISCV
bool
default "n"
Expand Down Expand Up @@ -606,6 +610,13 @@ mainmenu "Espressif IoT Development Framework Configuration"
Places orphan sections without a warning/error message.
endchoice

config COMPILER_STATIC_ANALYZER
bool "Enable compiler static analyzer"
default "n"
depends on IDF_TOOLCHAIN_GCC
help
Enable compiler static analyzer. This may produce false-positive results and increases compile time.

endmenu # Compiler Options

menu "Component config"
Expand Down
4 changes: 4 additions & 0 deletions components/console/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ idf_component_register(SRCS ${srcs}
PRIV_REQUIRES esp_driver_uart
esp_driver_usb_serial_jtag
)

if(CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TODO IDF-10085
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-analyzer")
endif()
5 changes: 5 additions & 0 deletions components/driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,9 @@ else()
esp_driver_uart esp_driver_ledc esp_driver_parlio esp_driver_usb_serial_jtag
LDFRAGMENTS ${ldfragments}
)
if(CONFIG_SOC_ADC_SUPPORTED AND
CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TODO GCC-366
set_source_files_properties(deprecated/adc_legacy.c
PROPERTIES COMPILE_FLAGS "-Wno-analyzer-use-of-uninitialized-value")
endif()
endif()
5 changes: 4 additions & 1 deletion components/driver/deprecated/rmt_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "hal/rmt_ll.h"
#include "hal/gpio_hal.h"
#include "esp_rom_gpio.h"
#include "esp_compiler.h"

#define RMT_CHANNEL_ERROR_STR "RMT CHANNEL ERR"
#define RMT_ADDR_ERROR_STR "RMT ADDRESS ERR"
Expand Down Expand Up @@ -1061,6 +1062,7 @@ esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr

#if SOC_RMT_SUPPORT_RX_PINGPONG
if (p_rmt_obj[channel]->rx_item_buf == NULL && rx_buf_size > 0) {
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") // False-positive detection. TODO GCC-366
#if !CONFIG_SPIRAM_USE_MALLOC
p_rmt_obj[channel]->rx_item_buf = calloc(1, rx_buf_size);
#else
Expand All @@ -1074,6 +1076,7 @@ esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr
ESP_LOGE(TAG, "RMT malloc fail");
return ESP_FAIL;
}
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
p_rmt_obj[channel]->rx_item_buf_size = rx_buf_size;
}
#endif
Expand Down Expand Up @@ -1237,7 +1240,7 @@ esp_err_t rmt_translator_get_context(const size_t *item_num, void **context)
{
ESP_RETURN_ON_FALSE(item_num && context, ESP_ERR_INVALID_ARG, TAG, "invalid arguments");

// the address of tx_len_rem is directlly passed to the callback,
// the address of tx_len_rem is directly passed to the callback,
// so it's possible to get the object address from that
rmt_obj_t *obj = __containerof(item_num, rmt_obj_t, tx_len_rem);
*context = obj->tx_context;
Expand Down
3 changes: 3 additions & 0 deletions components/driver/deprecated/rtc_temperature_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "esp_types.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_compiler.h"
#include "freertos/FreeRTOS.h"
#include "esp_private/regi2c_ctrl.h"
#include "soc/regi2c_saradc.h"
Expand Down Expand Up @@ -110,7 +111,9 @@ esp_err_t temp_sensor_stop(void)
esp_err_t temp_sensor_read_raw(uint32_t *tsens_out)
{
ESP_RETURN_ON_FALSE(tsens_out != NULL, ESP_ERR_INVALID_ARG, TAG, "no tsens_out specified");
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-use-of-uninitialized-value") // False-positive detection. TODO GCC-366
*tsens_out = temperature_sensor_ll_get_raw_value();
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-use-of-uninitialized-value")
return ESP_OK;
}

Expand Down
7 changes: 7 additions & 0 deletions components/efuse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,10 @@ set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_DIR}/test/esp_efuse_test_table.csv")
add_custom_target(efuse_test_table COMMAND "${python}"
"${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py"
${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG})

###################
# GNU analyzer excludes
if(CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TODO IDF-10086
set_source_files_properties(src/esp_efuse_utility.c
PROPERTIES COMPILE_FLAGS "-fno-analyzer")
endif()
3 changes: 3 additions & 0 deletions components/esp-tls/esp_tls_error_capture.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <sys/cdefs.h>
#include "esp_tls.h"
#include "esp_tls_error_capture_internal.h"
#include "esp_compiler.h"

typedef struct esp_tls_error_storage {
struct esp_tls_last_error parent; /*!< standard esp-tls last error container */
Expand Down Expand Up @@ -34,11 +35,13 @@ void esp_tls_internal_event_tracker_capture(esp_tls_error_handle_t h, uint32_t t

esp_tls_error_handle_t esp_tls_internal_event_tracker_create(void)
{
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak")
// Allocating internal error storage which extends the parent type
// `esp_tls_last_error` defined at interface level
struct esp_tls_error_storage* storage =
calloc(1, sizeof(struct esp_tls_error_storage));
return &storage->parent;
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
}

void esp_tls_internal_event_tracker_destroy(esp_tls_error_handle_t h)
Expand Down
32 changes: 30 additions & 2 deletions components/esp_common/include/esp_compiler.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -11,7 +11,7 @@
/*
* The likely and unlikely macro pairs:
* These macros are useful to place when application
* knows the majority ocurrence of a decision paths,
* knows the majority occurrence of a decision paths,
* placing one of these macros can hint the compiler
* to reorder instructions producing more optimized
* code.
Expand Down Expand Up @@ -52,3 +52,31 @@
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value,
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member)
#endif

#define __COMPILER_PRAGMA__(string) _Pragma(#string)
#define _COMPILER_PRAGMA_(string) __COMPILER_PRAGMA__(string)

#if __clang__
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning) \
__COMPILER_PRAGMA__(clang diagnostic push) \
__COMPILER_PRAGMA__(clang diagnostic ignored "-Wunknown-warning-option") \
__COMPILER_PRAGMA__(clang diagnostic ignored warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning) \
__COMPILER_PRAGMA__(clang diagnostic pop)
#elif __GNUC__
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning) \
__COMPILER_PRAGMA__(GCC diagnostic push) \
__COMPILER_PRAGMA__(GCC diagnostic ignored "-Wpragmas") \
__COMPILER_PRAGMA__(GCC diagnostic ignored warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning) \
__COMPILER_PRAGMA__(GCC diagnostic pop)
#else
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(warning)
#define ESP_COMPILER_DIAGNOSTIC_POP(warning)
#endif

#if __clang_analyzer__ || CONFIG_COMPILER_STATIC_ANALYZER
#define ESP_STATIC_ANALYZER_CHECK(_expr_, _ret_) do { if ((_expr_)) { return (_ret_); } } while(0)
#else
#define ESP_STATIC_ANALYZER_CHECK(_expr_, _ret_)
#endif
4 changes: 3 additions & 1 deletion components/esp_driver_parlio/src/parlio_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,12 @@ static void IRAM_ATTR parlio_tx_mount_dma_data(parlio_tx_unit_t *tx_unit, const
{
size_t prepared_length = 0;
uint8_t *data = (uint8_t *)buffer;
uint32_t mount_bytes = 0;
parlio_dma_desc_t *desc_nc = tx_unit->dma_nodes_nc;

while (len) {
uint32_t mount_bytes = len > DMA_DESCRIPTOR_BUFFER_MAX_SIZE ? DMA_DESCRIPTOR_BUFFER_MAX_SIZE : len;
assert(desc_nc);
mount_bytes = len > DMA_DESCRIPTOR_BUFFER_MAX_SIZE ? DMA_DESCRIPTOR_BUFFER_MAX_SIZE : len;
len -= mount_bytes;
desc_nc->dw0.suc_eof = (len == 0); // whether the last frame
desc_nc->dw0.size = mount_bytes;
Expand Down
2 changes: 2 additions & 0 deletions components/esp_driver_rmt/src/rmt_tx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,7 @@ static void IRAM_ATTR rmt_tx_default_isr(void *args)
}

#if SOC_RMT_SUPPORT_DMA
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-null-dereference") // TODO IDF-10235
static bool IRAM_ATTR rmt_dma_tx_eof_cb(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
{
rmt_tx_channel_t *tx_chan = (rmt_tx_channel_t *)user_data;
Expand All @@ -1132,4 +1133,5 @@ static bool IRAM_ATTR rmt_dma_tx_eof_cb(gdma_channel_handle_t dma_chan, gdma_eve
}
return false;
}
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-null-dereference")
#endif // SOC_RMT_SUPPORT_DMA
8 changes: 4 additions & 4 deletions components/esp_driver_usb_serial_jtag/src/usb_serial_jtag.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,15 @@ esp_err_t usb_serial_jtag_driver_install(usb_serial_jtag_driver_config_t *usb_se
ESP_RETURN_ON_FALSE((usb_serial_jtag_config->rx_buffer_size > USB_SER_JTAG_RX_MAX_SIZE), ESP_ERR_INVALID_ARG, USB_SERIAL_JTAG_TAG, "RX buffer prepared is so small, should larger than 64");
ESP_RETURN_ON_FALSE((usb_serial_jtag_config->tx_buffer_size > 0), ESP_ERR_INVALID_ARG, USB_SERIAL_JTAG_TAG, "TX buffer is not prepared");
p_usb_serial_jtag_obj = (usb_serial_jtag_obj_t*) heap_caps_calloc(1, sizeof(usb_serial_jtag_obj_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
p_usb_serial_jtag_obj->rx_buf_size = usb_serial_jtag_config->rx_buffer_size;
p_usb_serial_jtag_obj->tx_buf_size = usb_serial_jtag_config->tx_buffer_size;
p_usb_serial_jtag_obj->tx_stash_cnt = 0;
p_usb_serial_jtag_obj->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
if (p_usb_serial_jtag_obj == NULL) {
ESP_LOGE(USB_SERIAL_JTAG_TAG, "memory allocate error");
err = ESP_ERR_NO_MEM;
goto _exit;
}
p_usb_serial_jtag_obj->rx_buf_size = usb_serial_jtag_config->rx_buffer_size;
p_usb_serial_jtag_obj->tx_buf_size = usb_serial_jtag_config->tx_buffer_size;
p_usb_serial_jtag_obj->tx_stash_cnt = 0;
p_usb_serial_jtag_obj->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;

p_usb_serial_jtag_obj->rx_ring_buf = xRingbufferCreate(p_usb_serial_jtag_obj->rx_buf_size, RINGBUF_TYPE_BYTEBUF);
if (p_usb_serial_jtag_obj->rx_ring_buf == NULL) {
Expand Down
4 changes: 4 additions & 0 deletions components/esp_hw_support/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ idf_build_get_property(target IDF_TARGET)
add_subdirectory(port/${target})
add_subdirectory(lowpower)

if(CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TODO IDF-10229
target_compile_options(${COMPONENT_LIB} PRIVATE "-fno-analyzer")
endif()

if(NOT BOOTLOADER_BUILD)
if(CONFIG_SPIRAM)
idf_component_optional_requires(PRIVATE esp_psram)
Expand Down
2 changes: 1 addition & 1 deletion components/esp_hw_support/dma/gdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ static esp_err_t do_allocate_gdma_channel(const gdma_channel_search_info_t *sear

for (int i = start_group_id; i < end_group_id && search_code; i++) { // loop to search group
group = gdma_acquire_group_handle(i, search_info->hal_init);
group->bus_id = search_info->bus_id;
ESP_GOTO_ON_FALSE(group, ESP_ERR_NO_MEM, err, TAG, "no mem for group(%d)", i);
group->bus_id = search_info->bus_id;
for (int j = 0; j < pairs_per_group && search_code; j++) { // loop to search pair
pair = gdma_acquire_pair_handle(group, j);
ESP_GOTO_ON_FALSE(pair, ESP_ERR_NO_MEM, err, TAG, "no mem for pair(%d,%d)", i, j);
Expand Down
7 changes: 6 additions & 1 deletion components/esp_hw_support/esp_clock_output.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ static clkout_channel_handle_t* clkout_channel_alloc(soc_clkout_sig_id_t clk_sig
(s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].mapped_clock == clk_sig)) {
allocated_channel = &s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)];
}
allocated_channel->channel_id = (clock_out_channel_t)IONUM_TO_CLKOUT_CHANNEL(gpio_num);
if (allocated_channel != NULL) {
allocated_channel->channel_id = (clock_out_channel_t)IONUM_TO_CLKOUT_CHANNEL(gpio_num);
}
portEXIT_CRITICAL(&s_clkout_handle[IONUM_TO_CLKOUT_CHANNEL(gpio_num)].clkout_channel_lock);
#elif SOC_GPIO_CLOCKOUT_BY_GPIO_MATRIX
for (uint32_t channel = 0; channel < CLKOUT_CHANNEL_MAX; channel++) {
Expand Down Expand Up @@ -117,6 +119,9 @@ static esp_clock_output_mapping_t* clkout_mapping_alloc(clkout_channel_handle_t*

if (allocated_mapping == NULL) {
allocated_mapping = (esp_clock_output_mapping_t *)malloc(sizeof(esp_clock_output_mapping_t));
if (!allocated_mapping) {
return NULL;
}
allocated_mapping->mapped_io = gpio_num;
allocated_mapping->clkout_channel_hdl = channel_hdl;
allocated_mapping->ref_cnt = 0;
Expand Down
6 changes: 5 additions & 1 deletion components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v1.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -19,6 +19,7 @@
#include "driver/gpio.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_compiler.h"

static const char *TAG = "lcd_panel.io.i2c";

Expand Down Expand Up @@ -47,6 +48,8 @@ typedef struct {

esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_config_t *io_config, esp_lcd_panel_io_handle_t *ret_io)
{
// leak detection of i2c_panel_io because saving i2c_panel_io->base address
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak")
#if CONFIG_LCD_ENABLE_DEBUG_LOG
esp_log_level_set(TAG, ESP_LOG_DEBUG);
#endif
Expand Down Expand Up @@ -78,6 +81,7 @@ esp_err_t esp_lcd_new_panel_io_i2c_v1(uint32_t bus, const esp_lcd_panel_io_i2c_c
return ESP_OK;
err:
return ret;
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
}

static esp_err_t panel_io_i2c_del(esp_lcd_panel_io_t *io)
Expand Down
5 changes: 5 additions & 0 deletions components/esp_lcd/i2c/esp_lcd_panel_io_i2c_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "esp_check.h"
#include "freertos/FreeRTOS.h"
#include "esp_heap_caps.h"
#include "esp_compiler.h"

static const char *TAG = "lcd_panel.io.i2c";

#define BYTESHIFT(VAR, IDX) (((VAR) >> ((IDX) * 8)) & 0xFF)
Expand Down Expand Up @@ -56,6 +58,8 @@ esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd
i2c_master_dev_handle_t i2c_handle = NULL;
ESP_GOTO_ON_FALSE(io_config && ret_io, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
ESP_GOTO_ON_FALSE(io_config->control_phase_bytes * 8 > io_config->dc_bit_offset, ESP_ERR_INVALID_ARG, err, TAG, "D/C bit exceeds control bytes");
// leak detection of i2c_panel_io because saving i2c_panel_io->base address
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak")
i2c_panel_io = calloc(1, sizeof(lcd_panel_io_i2c_t));
ESP_GOTO_ON_FALSE(i2c_panel_io, ESP_ERR_NO_MEM, err, TAG, "no mem for i2c panel io");

Expand Down Expand Up @@ -88,6 +92,7 @@ esp_err_t esp_lcd_new_panel_io_i2c_v2(i2c_master_bus_handle_t bus, const esp_lcd
free(i2c_panel_io);
}
return ret;
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
}

static esp_err_t panel_io_i2c_del(esp_lcd_panel_io_t *io)
Expand Down
6 changes: 5 additions & 1 deletion components/esp_lcd/src/esp_lcd_panel_nt35510.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -24,6 +24,7 @@
#include "driver/gpio.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_compiler.h"

static const char *TAG = "lcd_panel.nt35510";

Expand Down Expand Up @@ -61,6 +62,8 @@ esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_pane
esp_err_t ret = ESP_OK;
nt35510_panel_t *nt35510 = NULL;
ESP_GOTO_ON_FALSE(io && panel_dev_config && ret_panel, ESP_ERR_INVALID_ARG, err, TAG, "invalid argument");
// leak detection of nt35510 because saving nt35510->base address
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak")
nt35510 = calloc(1, sizeof(nt35510_panel_t));
ESP_GOTO_ON_FALSE(nt35510, ESP_ERR_NO_MEM, err, TAG, "no mem for nt35510 panel");

Expand Down Expand Up @@ -131,6 +134,7 @@ esp_lcd_new_panel_nt35510(const esp_lcd_panel_io_handle_t io, const esp_lcd_pane
free(nt35510);
}
return ret;
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak")
}

static esp_err_t panel_nt35510_del(esp_lcd_panel_t *panel)
Expand Down
Loading

0 comments on commit b0ba568

Please sign in to comment.