From 0b52b3e62e93075bc6c8fba369cde8636c04e524 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 12:37:30 +0100 Subject: [PATCH 01/14] core/assert: remove panic include from assert.h --- core/assert.c | 16 +++++++++------- core/include/assert.h | 28 +++++++++++++++++----------- core/panic.c | 2 -- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/core/assert.c b/core/assert.c index 873634467d..853623d6b7 100644 --- a/core/assert.c +++ b/core/assert.c @@ -16,15 +16,17 @@ #include #include "assert.h" +#include "panic.h" -#ifdef DEBUG_ASSERT_VERBOSE -NORETURN void _assert_failure(const char *file, unsigned line) +__NORETURN void _assert_failure(const char *file, unsigned line) { - printf("%s:%u => ", file, line); \ - core_panic(PANIC_ASSERT_FAIL, assert_crash_message); \ + printf("%s:%u => ", file, line); + core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); +} + +__NORETURN void _assert_panic(void) +{ + core_panic(PANIC_ASSERT_FAIL, "FAILED ASSERTION."); } -#else -typedef int dont_be_pedantic; -#endif /** @} */ diff --git a/core/include/assert.h b/core/include/assert.h index bbfd8e35e7..4d8664bada 100644 --- a/core/include/assert.h +++ b/core/include/assert.h @@ -22,8 +22,6 @@ #ifndef ASSERT_H #define ASSERT_H -#include "panic.h" - #ifdef __cplusplus extern "C" { #endif @@ -51,9 +49,18 @@ extern "C" { #endif /** - * @brief the string that is passed to panic in case of a failing assertion - */ -extern const char assert_crash_message[]; + * @def __NORETURN + * @internal + * Duplicating the definitions of kernel_defines.h as these are unsuitable for + * system header files like the assert.h. + * kernel_defines.h would define symbols that are not reserved. */ +#ifndef __NORETURN +#ifdef __GNUC__ +#define __NORETURN __attribute__((noreturn)) +#else /*__GNUC__*/ +#define __NORETURN +#endif /*__GNUC__*/ +#endif /*__NORETURN*/ #ifdef NDEBUG #define assert(ignore)((void)0) @@ -68,8 +75,7 @@ extern const char assert_crash_message[]; * @param[in] file The file name of the file the assertion failed in * @param[in] line The code line of @p file the assertion failed in */ -NORETURN void _assert_failure(const char *file, unsigned line); - +__NORETURN void _assert_failure(const char *file, unsigned line); /** * @brief abort the program if assertion is false * @@ -103,10 +109,10 @@ NORETURN void _assert_failure(const char *file, unsigned line); */ #define assert(cond) ((cond) ? (void)0 : _assert_failure(RIOT_FILE_RELATIVE, \ __LINE__)) -#else -#define assert(cond) ((cond) ? (void)0 : core_panic(PANIC_ASSERT_FAIL, \ - assert_crash_message)) -#endif +#else /* DEBUG_ASSERT_VERBOSE */ +__NORETURN void _assert_panic(void); +#define assert(cond) ((cond) ? (void)0 : _assert_panic()) +#endif /* DEBUG_ASSERT_VERBOSE */ #if !defined __cplusplus #if __STDC_VERSION__ >= 201112L diff --git a/core/panic.c b/core/panic.c index 6f04d79481..5ccef7410f 100644 --- a/core/panic.c +++ b/core/panic.c @@ -43,8 +43,6 @@ #include "usb_board_reset.h" #endif -const char assert_crash_message[] = "FAILED ASSERTION."; - /* flag preventing "recursive crash printing loop" */ static int crashed = 0; From 909ffc9d3465c3186dad9f9c5ee2d4c6d4380afe Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 15:23:24 +0100 Subject: [PATCH 02/14] sys/fmt: include kernel_defines.h --- sys/fmt/fmt.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/fmt/fmt.c b/sys/fmt/fmt.c index 1d6a20a8d5..74fb79c016 100644 --- a/sys/fmt/fmt.c +++ b/sys/fmt/fmt.c @@ -31,6 +31,7 @@ ssize_t write(int fildes, const void *buf, size_t nbyte); #endif +#include "kernel_defines.h" #include "fmt.h" static const char _hex_chars[16] = "0123456789ABCDEF"; From 5e42af79351325675d235622b5cec935b8072bb1 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 15:29:31 +0100 Subject: [PATCH 03/14] cpu/stm32: i2c include panic.h --- cpu/stm32/periph/i2c_1.c | 1 + cpu/stm32/periph/i2c_2.c | 1 + 2 files changed, 2 insertions(+) diff --git a/cpu/stm32/periph/i2c_1.c b/cpu/stm32/periph/i2c_1.c index 464c584bef..d30cc27b3e 100644 --- a/cpu/stm32/periph/i2c_1.c +++ b/cpu/stm32/periph/i2c_1.c @@ -39,6 +39,7 @@ #include "cpu.h" #include "mutex.h" #include "byteorder.h" +#include "panic.h" #include "cpu_conf_stm32_common.h" diff --git a/cpu/stm32/periph/i2c_2.c b/cpu/stm32/periph/i2c_2.c index ebfb2dae53..c260a9cac9 100644 --- a/cpu/stm32/periph/i2c_2.c +++ b/cpu/stm32/periph/i2c_2.c @@ -42,6 +42,7 @@ #include "irq.h" #include "mutex.h" #include "pm_layered.h" +#include "panic.h" #include "periph/i2c.h" #include "periph/gpio.h" From e272fb18ed1e703234cfd89a7d767535e47603a4 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 15:53:39 +0100 Subject: [PATCH 04/14] board/msba2: include kernel_defines.h --- boards/msba2/include/periph_conf.h | 1 + 1 file changed, 1 insertion(+) diff --git a/boards/msba2/include/periph_conf.h b/boards/msba2/include/periph_conf.h index 4e2744b6cd..6e4dbb05b7 100644 --- a/boards/msba2/include/periph_conf.h +++ b/boards/msba2/include/periph_conf.h @@ -20,6 +20,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "kernel_defines.h" #ifdef __cplusplus extern "C" { From 124f8cd2a9b49fe21f557f504196642366f626ba Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 16:06:32 +0100 Subject: [PATCH 05/14] driver/disp_dev: include stddef.h --- drivers/disp_dev/disp_dev.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/disp_dev/disp_dev.c b/drivers/disp_dev/disp_dev.c index 5653d59656..daaeb001cd 100644 --- a/drivers/disp_dev/disp_dev.c +++ b/drivers/disp_dev/disp_dev.c @@ -20,6 +20,7 @@ #include #include +#include #include #include From 3bce72af2dc1679d29718976ecf89f318c72370c Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 16:14:10 +0100 Subject: [PATCH 06/14] sys/utlist: include stddef.h --- sys/include/utlist.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/include/utlist.h b/sys/include/utlist.h index 66b7f165db..b334aa68a0 100644 --- a/sys/include/utlist.h +++ b/sys/include/utlist.h @@ -39,6 +39,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /** @brief Version number */ #define UTLIST_VERSION 1.9.9 +#include #include From fc79d85bcccfdc059654824b29845a2f4f6f58ca Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 17:02:46 +0100 Subject: [PATCH 07/14] example/suit_update: include kernel_defines.h --- examples/suit_update/coap_handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/suit_update/coap_handler.c b/examples/suit_update/coap_handler.c index 69a12d6f80..e985ce6b2e 100644 --- a/examples/suit_update/coap_handler.c +++ b/examples/suit_update/coap_handler.c @@ -12,6 +12,7 @@ #include "net/nanocoap.h" #include "suit/transport/coap.h" +#include "kernel_defines.h" static ssize_t _riot_board_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, void *context) { From 49e99f712b5259f83e1d792910a0591f88d2a3fe Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Wed, 26 Jan 2022 18:25:10 +0100 Subject: [PATCH 08/14] net/gnrc: include kernel_defines.h --- sys/include/net/gnrc/ipv6/nib/pl.h | 1 + sys/include/net/gnrc/sixlowpan/ctx.h | 1 + 2 files changed, 2 insertions(+) diff --git a/sys/include/net/gnrc/ipv6/nib/pl.h b/sys/include/net/gnrc/ipv6/nib/pl.h index aebc798d4f..3de817c952 100644 --- a/sys/include/net/gnrc/ipv6/nib/pl.h +++ b/sys/include/net/gnrc/ipv6/nib/pl.h @@ -21,6 +21,7 @@ #define NET_GNRC_IPV6_NIB_PL_H #include +#include #if IS_USED(MODULE_EVTIMER) #include "evtimer.h" diff --git a/sys/include/net/gnrc/sixlowpan/ctx.h b/sys/include/net/gnrc/sixlowpan/ctx.h index 73aeb1b382..af982efd75 100644 --- a/sys/include/net/gnrc/sixlowpan/ctx.h +++ b/sys/include/net/gnrc/sixlowpan/ctx.h @@ -31,6 +31,7 @@ #include "net/ipv6/addr.h" #include "timex.h" +#include #ifdef __cplusplus extern "C" { From e03cf052ba6c378ee99551cb68cd5f99d74af588 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Thu, 27 Jan 2022 12:32:37 +0100 Subject: [PATCH 09/14] example/nanocoap_server: include kernel_defines.h --- examples/nanocoap_server/coap_handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/nanocoap_server/coap_handler.c b/examples/nanocoap_server/coap_handler.c index 9a916e12a5..1c07774249 100644 --- a/examples/nanocoap_server/coap_handler.c +++ b/examples/nanocoap_server/coap_handler.c @@ -13,6 +13,7 @@ #include "fmt.h" #include "net/nanocoap.h" #include "hashes/sha256.h" +#include "kernel_defines.h" /* internal value that can be read/written via CoAP */ static uint8_t internal_value = 0; From a0ecb4ec81ac12adee068c857e13ef3ffc12b6b0 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Thu, 27 Jan 2022 17:13:24 +0100 Subject: [PATCH 10/14] test/nanocoap_cli: include kernel_defines.h --- tests/nanocoap_cli/request_handlers.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/nanocoap_cli/request_handlers.c b/tests/nanocoap_cli/request_handlers.c index a6a672c75d..32b78254b4 100644 --- a/tests/nanocoap_cli/request_handlers.c +++ b/tests/nanocoap_cli/request_handlers.c @@ -25,6 +25,7 @@ #include "fmt.h" #include "net/nanocoap.h" +#include "kernel_defines.h" #define _MAX_PAYLOAD_LEN (16) From 766b3b613f7c152fe9e8a6fda8ece92edd4811cb Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Thu, 27 Jan 2022 22:41:14 +0100 Subject: [PATCH 11/14] saul/auto_init_sgp30: if is compiled there is saul --- drivers/saul/init_devs/auto_init_sgp30.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/drivers/saul/init_devs/auto_init_sgp30.c b/drivers/saul/init_devs/auto_init_sgp30.c index ef53c7980c..fcd2f0ddea 100644 --- a/drivers/saul/init_devs/auto_init_sgp30.c +++ b/drivers/saul/init_devs/auto_init_sgp30.c @@ -16,9 +16,7 @@ #include "assert.h" #include "log.h" -#if IS_USED(MODULE_SAUL) #include "saul_reg.h" -#endif #include "sgp30.h" #include "sgp30_params.h" @@ -28,7 +26,6 @@ */ static sgp30_t sgp30_devs[SGP30_NUM]; -#if IS_USED(MODULE_SAUL) /** * @brief Memory for the SAUL registry entries */ @@ -41,7 +38,6 @@ static saul_reg_t saul_entries[SGP30_NUM * 2]; extern const saul_driver_t sgp30_saul_driver_eco2; extern const saul_driver_t sgp30_saul_driver_tvoc; /** @} */ -#endif void auto_init_sgp30(void) { @@ -55,7 +51,6 @@ void auto_init_sgp30(void) continue; } -#if IS_USED(MODULE_SAUL) /* eCO2 */ saul_entries[(i * 2)].dev = &(sgp30_devs[i]); saul_entries[(i * 2)].name = sgp30_saul_info[i].name; @@ -69,6 +64,5 @@ void auto_init_sgp30(void) /* register to saul */ saul_reg_add(&(saul_entries[(i * 2)])); saul_reg_add(&(saul_entries[(i * 2) + 1])); -#endif } } From 76e0d53068cbd7318a4ce0a4ef7151b41540439d Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Thu, 27 Jan 2022 22:49:07 +0100 Subject: [PATCH 12/14] test/sys_architecture: include kernel_defines.h --- tests/sys_architecture/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/sys_architecture/main.c b/tests/sys_architecture/main.c index a51ce84c47..3984412810 100644 --- a/tests/sys_architecture/main.c +++ b/tests/sys_architecture/main.c @@ -23,6 +23,7 @@ #include "assert.h" #include "architecture.h" +#include "kernel_defines.h" /* On all but 8bit architectures, at least one of the following should be * misaligned */ From 29caf39a9a59b1c89ed788d5c7276749eb0ab431 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Sat, 12 Feb 2022 17:44:12 +0100 Subject: [PATCH 13/14] core/panic.c: cleanup unneeded includes --- core/panic.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/core/panic.c b/core/panic.c index 5ccef7410f..6ef8c03960 100644 --- a/core/panic.c +++ b/core/panic.c @@ -21,10 +21,6 @@ * @author Kaspar Schleiser */ -#include -#include - -#include "assert.h" #include "kernel_defines.h" #include "cpu.h" #include "irq.h" From ca112c224a3cec36531e3da230d225d35cb4c613 Mon Sep 17 00:00:00 2001 From: Karl Fessel Date: Tue, 15 Feb 2022 10:34:54 +0100 Subject: [PATCH 14/14] core/assert.h: doxygen brief for __NORETURN --- core/include/assert.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/include/assert.h b/core/include/assert.h index 4d8664bada..1e328596df 100644 --- a/core/include/assert.h +++ b/core/include/assert.h @@ -50,10 +50,13 @@ extern "C" { /** * @def __NORETURN + * @brief hidden (__) NORETURN definition * @internal + * * Duplicating the definitions of kernel_defines.h as these are unsuitable for * system header files like the assert.h. - * kernel_defines.h would define symbols that are not reserved. */ + * kernel_defines.h would define symbols that are not reserved. + */ #ifndef __NORETURN #ifdef __GNUC__ #define __NORETURN __attribute__((noreturn))