mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-04 21:24:32 +02:00
fix(build): fix -Wanalyzer-undefined-behavior-ptrdiff warnings
This commit is contained in:
@@ -29,7 +29,7 @@ esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
|
||||
|
||||
void bootloader_clear_bss_section(void)
|
||||
{
|
||||
memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start));
|
||||
memset(&_bss_start, 0, (uintptr_t)&_bss_end - (uintptr_t)&_bss_start);
|
||||
}
|
||||
|
||||
esp_err_t bootloader_read_bootloader_header(void)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -119,11 +119,11 @@ static esp_err_t esp_sleep_tagmem_pd_low_init(void)
|
||||
if (s_tag_mem->link_addr == NULL) {
|
||||
extern char _stext[], _etext[];
|
||||
uint32_t code_start = (uint32_t)_stext;
|
||||
uint32_t code_size = (uint32_t)(_etext - _stext);
|
||||
uint32_t code_size = (uint32_t)((uintptr_t)_etext - (uintptr_t)_stext);
|
||||
#if !(CONFIG_SPIRAM && CONFIG_SOC_PM_SUPPORT_TAGMEM_PD)
|
||||
extern char _rodata_start[], _rodata_reserved_end[];
|
||||
uint32_t data_start = (uint32_t)_rodata_start;
|
||||
uint32_t data_size = (uint32_t)(_rodata_reserved_end - _rodata_start);
|
||||
uint32_t data_size = (uint32_t)((uintptr_t)_rodata_reserved_end - (uintptr_t)_rodata_start);
|
||||
#else
|
||||
uint32_t data_start = SOC_DROM_LOW;
|
||||
uint32_t data_size = SOC_EXTRAM_DATA_SIZE;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2020-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -73,11 +73,11 @@ void rom_usb_cdc_set_descriptor_patch(void)
|
||||
void usb_dev_deinit(void)
|
||||
{
|
||||
extern char rom_usb_dev, rom_usb_dev_end;
|
||||
memset((void *) &rom_usb_dev, 0, &rom_usb_dev_end - &rom_usb_dev);
|
||||
memset((void *) &rom_usb_dev, 0, (uintptr_t)&rom_usb_dev_end - (uintptr_t)&rom_usb_dev);
|
||||
}
|
||||
|
||||
void usb_dw_ctrl_deinit(void)
|
||||
{
|
||||
extern char rom_usb_dw_ctrl, rom_usb_dw_ctrl_end;
|
||||
memset((void *) &rom_usb_dw_ctrl, 0, &rom_usb_dw_ctrl_end - &rom_usb_dw_ctrl);
|
||||
memset((void *) &rom_usb_dw_ctrl, 0, (uintptr_t)&rom_usb_dw_ctrl_end - (uintptr_t)&rom_usb_dw_ctrl);
|
||||
}
|
||||
|
@@ -417,26 +417,26 @@ FORCE_INLINE_ATTR IRAM_ATTR void get_reset_reason(soc_reset_reason_t *rst_reas)
|
||||
FORCE_INLINE_ATTR IRAM_ATTR void init_bss(const soc_reset_reason_t *rst_reas)
|
||||
{
|
||||
#if SOC_MEM_NON_CONTIGUOUS_SRAM
|
||||
memset(&_bss_start_low, 0, (&_bss_end_low - &_bss_start_low) * sizeof(_bss_start_low));
|
||||
memset(&_bss_start_high, 0, (&_bss_end_high - &_bss_start_high) * sizeof(_bss_start_high));
|
||||
memset(&_bss_start_low, 0, (uintptr_t)&_bss_end_low - (uintptr_t)&_bss_start_low);
|
||||
memset(&_bss_start_high, 0, (uintptr_t)&_bss_end_high - (uintptr_t)&_bss_start_high);
|
||||
#else
|
||||
memset(&_bss_start, 0, (&_bss_end - &_bss_start) * sizeof(_bss_start));
|
||||
memset(&_bss_start, 0, (uintptr_t)&_bss_end - (uintptr_t)&_bss_start);
|
||||
#endif // SOC_MEM_NON_CONTIGUOUS_SRAM
|
||||
|
||||
#if CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
// Clear Bluetooth bss
|
||||
memset(&_bss_bt_start, 0, (&_bss_bt_end - &_bss_bt_start) * sizeof(_bss_bt_start));
|
||||
memset(&_bss_bt_start, 0, (uintptr_t)&_bss_bt_end - (uintptr_t)&_bss_bt_start);
|
||||
#endif // CONFIG_BT_LE_RELEASE_IRAM_SUPPORTED
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32) && defined(CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY)
|
||||
// Clear IRAM BSS
|
||||
memset(&_iram_bss_start, 0, (&_iram_bss_end - &_iram_bss_start) * sizeof(_iram_bss_start));
|
||||
memset(&_iram_bss_start, 0, (uintptr_t)&_iram_bss_end - (uintptr_t)&_iram_bss_start);
|
||||
#endif
|
||||
|
||||
#if SOC_RTC_FAST_MEM_SUPPORTED || SOC_RTC_SLOW_MEM_SUPPORTED
|
||||
/* Unless waking from deep sleep (implying RTC memory is intact), clear RTC bss */
|
||||
if (rst_reas[0] != RESET_REASON_CORE_DEEP_SLEEP) {
|
||||
memset(&_rtc_bss_start, 0, (&_rtc_bss_end - &_rtc_bss_start) * sizeof(_rtc_bss_start));
|
||||
memset(&_rtc_bss_start, 0, (uintptr_t)&_rtc_bss_end - (uintptr_t)&_rtc_bss_start);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2018-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -25,8 +25,9 @@ extern soc_reserved_region_t soc_reserved_memory_region_end;
|
||||
|
||||
static size_t s_get_num_reserved_regions(void)
|
||||
{
|
||||
size_t result = ( &soc_reserved_memory_region_end
|
||||
- &soc_reserved_memory_region_start );
|
||||
size_t result = (uintptr_t)&soc_reserved_memory_region_end - (uintptr_t)&soc_reserved_memory_region_start;
|
||||
result /= sizeof(soc_reserved_region_t);
|
||||
|
||||
#if ESP_ROM_HAS_LAYOUT_TABLE
|
||||
return result + 1; // ROM table means one entry needs to be added at runtime
|
||||
#else
|
||||
|
@@ -335,7 +335,7 @@ esp_err_t esp_crt_bundle_attach(void *conf)
|
||||
esp_err_t ret = ESP_OK;
|
||||
// If no bundle has been set by the user then use the bundle embedded in the binary
|
||||
if (s_crt_bundle == NULL) {
|
||||
ret = esp_crt_bundle_init(x509_crt_imported_bundle_bin_start, x509_crt_imported_bundle_bin_end - x509_crt_imported_bundle_bin_start);
|
||||
ret = esp_crt_bundle_init(x509_crt_imported_bundle_bin_start, (uintptr_t)x509_crt_imported_bundle_bin_end - (uintptr_t)x509_crt_imported_bundle_bin_start);
|
||||
}
|
||||
|
||||
if (unlikely(ret != ESP_OK)) {
|
||||
|
Reference in New Issue
Block a user