one-based indexing enums is not cool
Fixes possible out of array bounds introduced in 5af710ff73
This commit is contained in:
parent
462a1c8c0d
commit
de96d8ba06
|
@ -75,7 +75,8 @@
|
|||
#endif
|
||||
|
||||
#if HAL_USE_SPI
|
||||
extern bool isSpiInitialized[SPI_TOTAL_COUNT];
|
||||
/* zero index is SPI_NONE */
|
||||
extern bool isSpiInitialized[SPI_TOTAL_COUNT + 1];
|
||||
|
||||
/**
|
||||
* Only one consumer can use SPI bus at a given time
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include "pch.h"
|
||||
|
||||
#if HAL_USE_SPI
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT] = { false, false, false, false, false, false };
|
||||
/* zero index is SPI_NONE */
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT + 1] = { true, false, false, false, false, false, false };
|
||||
|
||||
struct af_pairs {
|
||||
brain_pin_e pin;
|
||||
|
|
|
@ -65,7 +65,8 @@ void HardFaultVector(void) {
|
|||
}
|
||||
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT] = { false, false, false, false, false, false };
|
||||
/* zero index is SPI_NONE */
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT + 1] = { true, false, false, false, false, false, false };
|
||||
|
||||
static int getSpiAf(SPIDriver *driver) {
|
||||
#if STM32_SPI_USE_SPI1
|
||||
|
|
|
@ -58,7 +58,8 @@ void HardFaultVector(void) {
|
|||
}
|
||||
|
||||
#if HAL_USE_SPI || defined(__DOXYGEN__)
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT] = { false, false, false, false, false, false };
|
||||
/* zero index is SPI_NONE */
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT + 1] = { true, false, false, false, false, false, false };
|
||||
|
||||
static int getSpiAf(SPIDriver *driver) {
|
||||
#if STM32_SPI_USE_SPI1
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
#include "pch.h"
|
||||
|
||||
#if HAL_USE_SPI
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT] = { false, false, false, false, false, false };
|
||||
/* zero index is SPI_NONE */
|
||||
bool isSpiInitialized[SPI_TOTAL_COUNT + 1] = { true, false, false, false, false, false, false };
|
||||
|
||||
static int getSpiAf(SPIDriver *driver) {
|
||||
#if STM32_SPI_USE_SPI1
|
||||
|
|
Loading…
Reference in New Issue