mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-14 17:13:50 +01:00
cpu/cc26xx_cc13xx: Fix bogus array-bound warning
GCC 12 create a bogus array out of bounds warning as it assumes that
because there is special handling for `uart == 0` and `uart == 1`,
`uart` can indeed be `1`. There is an `assert(uart < UART_NUMOF)` above
that would blow up prior to any out of bounds access.
In any case, optimizing out the special handling of `uart == 1` for
when `UART_NUMOF == 1` likely improves the generated code and fixes
the warning.
/home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:88:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
88 | ctx[uart].rx_cb = rx_cb;
| ~~~^~~~~~
/home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
52 | static uart_isr_ctx_t ctx[UART_NUMOF];
| ^~~
/home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:89:8: error: array subscript 1 is above array bounds of 'uart_isr_ctx_t[1]' [-Werror=array-bounds]
89 | ctx[uart].arg = arg;
| ~~~^~~~~~
/home/maribu/Repos/software/RIOT/cc2650/cpu/cc26xx_cc13xx/periph/uart.c:52:23: note: while referencing 'ctx'
52 | static uart_isr_ctx_t ctx[UART_NUMOF];
| ^~~
This commit is contained in:
parent
8b58e55580
commit
d6499fa8fd
@ -64,7 +64,7 @@ int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg)
|
|||||||
int cts_pin = uart_config[uart].cts_pin;
|
int cts_pin = uart_config[uart].cts_pin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (uart == 0) {
|
if ((UART_NUMOF == 1) || (uart == 0)) {
|
||||||
/* UART0 requires serial domain to be enabled */
|
/* UART0 requires serial domain to be enabled */
|
||||||
if (!power_is_domain_enabled(POWER_DOMAIN_SERIAL)) {
|
if (!power_is_domain_enabled(POWER_DOMAIN_SERIAL)) {
|
||||||
power_enable_domain(POWER_DOMAIN_SERIAL);
|
power_enable_domain(POWER_DOMAIN_SERIAL);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user