From 586c26f9c083872566176e9f51918fae6858c808 Mon Sep 17 00:00:00 2001 From: emb4fun Date: Sat, 25 Mar 2023 14:57:55 +0100 Subject: [PATCH 1/3] Remove warnings --- sw/lib/source/neorv32_rte.c | 4 ++++ sw/lib/source/neorv32_uart.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/sw/lib/source/neorv32_rte.c b/sw/lib/source/neorv32_rte.c index 79823bd5f..74e4046fe 100644 --- a/sw/lib/source/neorv32_rte.c +++ b/sw/lib/source/neorv32_rte.c @@ -83,6 +83,8 @@ void neorv32_rte_setup(void) { } } +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wtype-limits" /**********************************************************************//** * Install trap handler function to NEORV32 runtime environment. @@ -119,6 +121,8 @@ int neorv32_rte_handler_uninstall(uint8_t id) { return 1; } +#pragma GCC diagnostic pop + /**********************************************************************//** * This is the [private!] core of the NEORV32 RTE. diff --git a/sw/lib/source/neorv32_uart.c b/sw/lib/source/neorv32_uart.c index 9c19f77e8..15ae353ea 100644 --- a/sw/lib/source/neorv32_uart.c +++ b/sw/lib/source/neorv32_uart.c @@ -61,10 +61,10 @@ int neorv32_uart_available (neorv32_uart_t *UARTx) { int available = 0; - if ( ((int)UARTx == NEORV32_UART0_BASE) && (NEORV32_SYSINFO->SOC & (1 << SYSINFO_SOC_IO_UART0)) ) { + if ( ((uint32_t)UARTx == NEORV32_UART0_BASE) && (NEORV32_SYSINFO->SOC & (1 << SYSINFO_SOC_IO_UART0)) ) { available = 1; } - if ( ((int)UARTx == NEORV32_UART1_BASE) && (NEORV32_SYSINFO->SOC & (1 << SYSINFO_SOC_IO_UART1)) ) { + if ( ((uint32_t)UARTx == NEORV32_UART1_BASE) && (NEORV32_SYSINFO->SOC & (1 << SYSINFO_SOC_IO_UART1)) ) { available = 1; } return(available); From f024dd3b78291b7e80e951582d02cae340892c3c Mon Sep 17 00:00:00 2001 From: emb4fun Date: Sat, 8 Apr 2023 13:35:03 +0200 Subject: [PATCH 2/3] Warning removed --- sw/lib/source/neorv32_rte.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sw/lib/source/neorv32_rte.c b/sw/lib/source/neorv32_rte.c index 8fd179c9a..28ad64849 100644 --- a/sw/lib/source/neorv32_rte.c +++ b/sw/lib/source/neorv32_rte.c @@ -83,8 +83,6 @@ void neorv32_rte_setup(void) { } } -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wtype-limits" /**********************************************************************//** * Install trap handler function to NEORV32 runtime environment. @@ -93,10 +91,10 @@ void neorv32_rte_setup(void) { * @param[in] handler The actual handler function for the specified trap (function MUST be of type "void function(void);"). * @return 0 if success, 1 if error (invalid id or targeted trap not supported). **************************************************************************/ -int neorv32_rte_handler_install(uint8_t id, void (*handler)(void)) { +int neorv32_rte_handler_install(enum NEORV32_RTE_TRAP_enum id, void (*handler)(void)) { // id valid? - if ((id >= RTE_TRAP_I_MISALIGNED) && (id <= RTE_TRAP_FIRQ_15)) { + if (id <= RTE_TRAP_FIRQ_15) { __neorv32_rte_vector_lut[id] = (uint32_t)handler; // install handler return 0; } @@ -111,18 +109,16 @@ int neorv32_rte_handler_install(uint8_t id, void (*handler)(void)) { * @param[in] id Identifier (type) of the targeted trap. See #NEORV32_RTE_TRAP_enum. * @return 0 if success, 1 if error (invalid id or targeted trap not supported). **************************************************************************/ -int neorv32_rte_handler_uninstall(uint8_t id) { +int neorv32_rte_handler_uninstall(enum NEORV32_RTE_TRAP_enum id) { // id valid? - if ((id >= RTE_TRAP_I_MISALIGNED) && (id <= RTE_TRAP_FIRQ_15)) { + if (id <= RTE_TRAP_FIRQ_15) { __neorv32_rte_vector_lut[id] = (uint32_t)(&__neorv32_rte_debug_handler); // use dummy handler in case the trap is accidentally triggered return 0; } return 1; } -#pragma GCC diagnostic pop - /**********************************************************************//** * This is the [private!] core of the NEORV32 RTE. From f8b96fe07a7d90e6396beb7163fdb0e296976b9f Mon Sep 17 00:00:00 2001 From: emb4fun Date: Sat, 8 Apr 2023 13:48:08 +0200 Subject: [PATCH 3/3] Try again to remove the warnings --- sw/lib/include/neorv32_rte.h | 4 ++-- sw/lib/source/neorv32_rte.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sw/lib/include/neorv32_rte.h b/sw/lib/include/neorv32_rte.h index 233527b13..168ef5589 100644 --- a/sw/lib/include/neorv32_rte.h +++ b/sw/lib/include/neorv32_rte.h @@ -89,8 +89,8 @@ enum NEORV32_RTE_TRAP_enum { **************************************************************************/ /**@{*/ void neorv32_rte_setup(void); -int neorv32_rte_handler_install(uint8_t id, void (*handler)(void)); -int neorv32_rte_handler_uninstall(uint8_t id); +int neorv32_rte_handler_install(int id, void (*handler)(void)); +int neorv32_rte_handler_uninstall(int id); void neorv32_rte_print_hw_config(void); void neorv32_rte_print_hw_version(void); diff --git a/sw/lib/source/neorv32_rte.c b/sw/lib/source/neorv32_rte.c index 28ad64849..3ab985615 100644 --- a/sw/lib/source/neorv32_rte.c +++ b/sw/lib/source/neorv32_rte.c @@ -91,10 +91,10 @@ void neorv32_rte_setup(void) { * @param[in] handler The actual handler function for the specified trap (function MUST be of type "void function(void);"). * @return 0 if success, 1 if error (invalid id or targeted trap not supported). **************************************************************************/ -int neorv32_rte_handler_install(enum NEORV32_RTE_TRAP_enum id, void (*handler)(void)) { +int neorv32_rte_handler_install(int id, void (*handler)(void)) { // id valid? - if (id <= RTE_TRAP_FIRQ_15) { + if ((id >= (int)RTE_TRAP_I_MISALIGNED) && (id <= (int)RTE_TRAP_FIRQ_15)) { __neorv32_rte_vector_lut[id] = (uint32_t)handler; // install handler return 0; } @@ -109,10 +109,10 @@ int neorv32_rte_handler_install(enum NEORV32_RTE_TRAP_enum id, void (*handler)(v * @param[in] id Identifier (type) of the targeted trap. See #NEORV32_RTE_TRAP_enum. * @return 0 if success, 1 if error (invalid id or targeted trap not supported). **************************************************************************/ -int neorv32_rte_handler_uninstall(enum NEORV32_RTE_TRAP_enum id) { +int neorv32_rte_handler_uninstall(int id) { // id valid? - if (id <= RTE_TRAP_FIRQ_15) { + if ((id >= (int)RTE_TRAP_I_MISALIGNED) && (id <= (int)RTE_TRAP_FIRQ_15)) { __neorv32_rte_vector_lut[id] = (uint32_t)(&__neorv32_rte_debug_handler); // use dummy handler in case the trap is accidentally triggered return 0; }