From fa099f23f37239418a3ee1ec65a7eb54319e41d8 Mon Sep 17 00:00:00 2001 From: Jakob Hasse Date: Thu, 11 May 2023 10:40:49 +0800 Subject: [PATCH] compiler: replaced noreturn by __noreturn__ in header files * noreturn may be replaced by third-party macros, rendering it ineffective * Closes https://github.com/espressif/esp-idf/issues/11339 --- .../private_include/bootloader_utility.h | 4 ++-- components/esp_common/include/esp_err.h | 2 +- components/esp_hw_support/include/esp_sleep.h | 4 ++-- components/esp_rom/include/esp32/rom/rtc.h | 2 +- .../esp_rom/include/esp32c2/rom/libc_stubs.h | 2 +- .../esp_rom/include/esp32c3/rom/libc_stubs.h | 20 ++++++------------- .../esp_rom/include/esp32h2/rom/libc_stubs.h | 20 ++++++------------- .../esp_rom/include/esp32s3/rom/libc_stubs.h | 20 ++++++------------- .../include/esp_private/panic_internal.h | 20 ++++++------------- components/esp_system/include/esp_system.h | 4 ++-- .../port/include/port/panic_funcs.h | 2 +- .../ulp_core/include/ulp_riscv_utils.h | 2 +- tools/ci/check_copyright_ignore.txt | 4 ---- 13 files changed, 35 insertions(+), 71 deletions(-) diff --git a/components/bootloader_support/private_include/bootloader_utility.h b/components/bootloader_support/private_include/bootloader_utility.h index e072d7d76a..77d4a9eee0 100644 --- a/components/bootloader_support/private_include/bootloader_utility.h +++ b/components/bootloader_support/private_include/bootloader_utility.h @@ -45,7 +45,7 @@ int bootloader_utility_get_selected_boot_partition(const bootloader_state_t *bs) * @param[in] bs Bootloader state structure. * @param[in] start_index The index from which the search for images begins. */ -__attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index); +__attribute__((__noreturn__)) void bootloader_utility_load_boot_image(const bootloader_state_t *bs, int start_index); #ifdef CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP /** @@ -65,7 +65,7 @@ void bootloader_utility_load_boot_image_from_deep_sleep(void); * * It is not recommended to call this function from an app (if called, the app will abort). */ -__attribute__((noreturn)) void bootloader_reset(void); +__attribute__((__noreturn__)) void bootloader_reset(void); /** * @brief Do any cleanup before exiting the bootloader, before starting the app or resetting diff --git a/components/esp_common/include/esp_err.h b/components/esp_common/include/esp_err.h index 34e69d3c0d..d6b2e301d2 100644 --- a/components/esp_common/include/esp_err.h +++ b/components/esp_common/include/esp_err.h @@ -76,7 +76,7 @@ const char *esp_err_to_name(esp_err_t code); const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen); /** @cond */ -void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn)); +void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((__noreturn__)); /** @cond */ void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression); diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index ec45b24e64..516c99ba3b 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -364,7 +364,7 @@ esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain, * * This function does not return. */ -void esp_deep_sleep_start(void) __attribute__((noreturn)); +void esp_deep_sleep_start(void) __attribute__((__noreturn__)); /** * @brief Enter light sleep with the configured wakeup options @@ -402,7 +402,7 @@ esp_err_t esp_light_sleep_start(void); * * @param time_in_us deep-sleep time, unit: microsecond */ -void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn)); +void esp_deep_sleep(uint64_t time_in_us) __attribute__((__noreturn__)); /** diff --git a/components/esp_rom/include/esp32/rom/rtc.h b/components/esp_rom/include/esp32/rom/rtc.h index 66608bb181..101b4bf56b 100644 --- a/components/esp_rom/include/esp32/rom/rtc.h +++ b/components/esp_rom/include/esp32/rom/rtc.h @@ -217,7 +217,7 @@ static inline void rtc_suppress_rom_log(void) * * @return None */ -void __attribute__((noreturn)) software_reset(void); +void __attribute__((__noreturn__)) software_reset(void); /** * @brief Software Reset digital core. diff --git a/components/esp_rom/include/esp32c2/rom/libc_stubs.h b/components/esp_rom/include/esp32c2/rom/libc_stubs.h index 94992b0457..eb31357fc2 100644 --- a/components/esp_rom/include/esp32c2/rom/libc_stubs.h +++ b/components/esp_rom/include/esp32c2/rom/libc_stubs.h @@ -69,7 +69,7 @@ struct syscall_stub_table void (*_retarget_lock_release_recursive)(_LOCK_T lock); int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); - void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn)); + void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((__noreturn__)); void (*__sinit) (struct _reent *r); void (*_cleanup_r) (struct _reent* r); }; diff --git a/components/esp_rom/include/esp32c3/rom/libc_stubs.h b/components/esp_rom/include/esp32c3/rom/libc_stubs.h index 233355e9c2..7008b48794 100644 --- a/components/esp_rom/include/esp32c3/rom/libc_stubs.h +++ b/components/esp_rom/include/esp32c3/rom/libc_stubs.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LIBC_STUBS_H_ #define _ROM_LIBC_STUBS_H_ @@ -77,7 +69,7 @@ struct syscall_stub_table void (*_retarget_lock_release_recursive)(_LOCK_T lock); int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); - void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn)); + void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((__noreturn__)); void (*__sinit) (struct _reent *r); void (*_cleanup_r) (struct _reent* r); }; diff --git a/components/esp_rom/include/esp32h2/rom/libc_stubs.h b/components/esp_rom/include/esp32h2/rom/libc_stubs.h index df78851c1b..18964567d8 100644 --- a/components/esp_rom/include/esp32h2/rom/libc_stubs.h +++ b/components/esp_rom/include/esp32h2/rom/libc_stubs.h @@ -1,16 +1,8 @@ -// Copyright 2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef _ROM_LIBC_STUBS_H_ #define _ROM_LIBC_STUBS_H_ @@ -90,7 +82,7 @@ struct syscall_stub_table #endif int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); - void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn)); + void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((__noreturn__)); void (*__sinit) (struct _reent *r); void (*_cleanup_r) (struct _reent* r); }; diff --git a/components/esp_rom/include/esp32s3/rom/libc_stubs.h b/components/esp_rom/include/esp32s3/rom/libc_stubs.h index 1298eeda55..47050b543e 100644 --- a/components/esp_rom/include/esp32s3/rom/libc_stubs.h +++ b/components/esp_rom/include/esp32s3/rom/libc_stubs.h @@ -1,16 +1,8 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -78,7 +70,7 @@ struct syscall_stub_table void (*_retarget_lock_release_recursive)(_LOCK_T lock); int (*_printf_float)(struct _reent *data, void *pdata, FILE * fp, int (*pfunc) (struct _reent *, FILE *, const char *, size_t len), va_list * ap); int (*_scanf_float) (struct _reent *rptr, void *pdata, FILE *fp, va_list *ap); - void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((noreturn)); + void (*__assert_func) (const char *file, int line, const char * func, const char *failedexpr) __attribute__((__noreturn__)); void (*__sinit) (struct _reent *r); void (*_cleanup_r) (struct _reent* r); }; diff --git a/components/esp_system/include/esp_private/panic_internal.h b/components/esp_system/include/esp_private/panic_internal.h index d43a705aba..bdf8a26420 100644 --- a/components/esp_system/include/esp_private/panic_internal.h +++ b/components/esp_system/include/esp_private/panic_internal.h @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #pragma once @@ -76,7 +68,7 @@ void panic_print_hex(int h); #define panic_print_hex(h) #endif -void __attribute__((noreturn)) panic_abort(const char *details); +void __attribute__((__noreturn__)) panic_abort(const char *details); void panic_arch_fill_info(void *frame, panic_info_t *info); diff --git a/components/esp_system/include/esp_system.h b/components/esp_system/include/esp_system.h index fea13af97d..f3ee93c002 100644 --- a/components/esp_system/include/esp_system.h +++ b/components/esp_system/include/esp_system.h @@ -72,7 +72,7 @@ esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handle); * Peripherals (except for Wi-Fi, BT, UART0, SPI1, and legacy timers) are not reset. * This function does not return. */ -void esp_restart(void) __attribute__ ((noreturn)); +void esp_restart(void) __attribute__ ((__noreturn__)); /** * @brief Get reason of last reset @@ -112,7 +112,7 @@ uint32_t esp_get_minimum_free_heap_size( void ); * * @param details Details that will be displayed during panic handling. */ -void __attribute__((noreturn)) esp_system_abort(const char* details); +void __attribute__((__noreturn__)) esp_system_abort(const char* details); #ifdef __cplusplus } diff --git a/components/esp_system/port/include/port/panic_funcs.h b/components/esp_system/port/include/port/panic_funcs.h index c2b4280051..9c317f9ce4 100644 --- a/components/esp_system/port/include/port/panic_funcs.h +++ b/components/esp_system/port/include/port/panic_funcs.h @@ -10,7 +10,7 @@ extern "C" { #endif -void __attribute__((noreturn)) panic_restart(void); +void __attribute__((__noreturn__)) panic_restart(void); #ifdef __cplusplus } diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h b/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h index a53b949b2b..92bb92689c 100644 --- a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h +++ b/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_utils.h @@ -53,7 +53,7 @@ void ulp_riscv_rescue_from_monitor(void); * put the ULP in monitor mode and triggers a reset. * */ -void __attribute__((noreturn)) ulp_riscv_halt(void); +void __attribute__((__noreturn__)) ulp_riscv_halt(void); #define ulp_riscv_shutdown ulp_riscv_halt diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 290c098ff6..0cc172057b 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -526,7 +526,6 @@ components/esp_rom/include/esp32c3/rom/digital_signature.h components/esp_rom/include/esp32c3/rom/esp_flash.h components/esp_rom/include/esp32c3/rom/ets_sys.h components/esp_rom/include/esp32c3/rom/hmac.h -components/esp_rom/include/esp32c3/rom/libc_stubs.h components/esp_rom/include/esp32c3/rom/md5_hash.h components/esp_rom/include/esp32c3/rom/rom_layout.h components/esp_rom/include/esp32c3/rom/rsa_pss.h @@ -542,7 +541,6 @@ components/esp_rom/include/esp32h2/rom/digital_signature.h components/esp_rom/include/esp32h2/rom/esp_flash.h components/esp_rom/include/esp32h2/rom/ets_sys.h components/esp_rom/include/esp32h2/rom/hmac.h -components/esp_rom/include/esp32h2/rom/libc_stubs.h components/esp_rom/include/esp32h2/rom/md5_hash.h components/esp_rom/include/esp32h2/rom/rsa_pss.h components/esp_rom/include/esp32h2/rom/sha.h @@ -579,7 +577,6 @@ components/esp_rom/include/esp32s3/rom/crc.h components/esp_rom/include/esp32s3/rom/digital_signature.h components/esp_rom/include/esp32s3/rom/ets_sys.h components/esp_rom/include/esp32s3/rom/hmac.h -components/esp_rom/include/esp32s3/rom/libc_stubs.h components/esp_rom/include/esp32s3/rom/md5_hash.h components/esp_rom/include/esp32s3/rom/opi_flash.h components/esp_rom/include/esp32s3/rom/rom_layout.h @@ -623,7 +620,6 @@ components/esp_system/include/esp_expression_with_stack.h components/esp_system/include/esp_freertos_hooks.h components/esp_system/include/esp_int_wdt.h components/esp_system/include/esp_private/dbg_stubs.h -components/esp_system/include/esp_private/panic_internal.h components/esp_system/port/arch/riscv/expression_with_stack.c components/esp_system/port/arch/xtensa/expression_with_stack.c components/esp_system/port/public_compat/brownout.h