diff --git a/src/main/drivers/dshot.c b/src/main/drivers/dshot.c index 54bfe2a4ed..d39a5531f1 100644 --- a/src/main/drivers/dshot.c +++ b/src/main/drivers/dshot.c @@ -306,7 +306,7 @@ FAST_CODE_NOINLINE void updateDshotTelemetry(void) return; } - const unsigned motorCount = dshotMotorCount; + const unsigned motorCount = MIN(MAX_SUPPORTED_MOTORS, dshotMotorCount); uint32_t erpmTotal = 0; uint32_t rpmSamples = 0; diff --git a/src/main/pg/board.c b/src/main/pg/board.c index ace8621eef..607a2e6964 100644 --- a/src/main/pg/board.c +++ b/src/main/pg/board.c @@ -38,8 +38,10 @@ PG_REGISTER_WITH_RESET_FN(boardConfig_t, boardConfig, PG_BOARD_CONFIG, 0); void pgResetFn_boardConfig(boardConfig_t *boardConfig) { if (boardInformationIsSet()) { - strncpy(boardConfig->manufacturerId, getManufacturerId(), MAX_MANUFACTURER_ID_LENGTH + 1); - strncpy(boardConfig->boardName, getBoardName(), MAX_BOARD_NAME_LENGTH + 1); + strncpy(boardConfig->manufacturerId, getManufacturerId(), sizeof(boardConfig->manufacturerId) - 1); + boardConfig->manufacturerId[sizeof(boardConfig->manufacturerId) - 1] = 0; // ensure zero-termination of string + strncpy(boardConfig->boardName, getBoardName(), sizeof(boardConfig->boardName) - 1); + boardConfig->boardName[sizeof(boardConfig->boardName) - 1] = 0; // ensure zero-termination of string boardConfig->boardInformationSet = true; } else { boardConfig->boardInformationSet = false; diff --git a/src/platform/STM32/sdio_f4xx.c b/src/platform/STM32/sdio_f4xx.c index 6b944a020b..ec64647c3f 100644 --- a/src/platform/STM32/sdio_f4xx.c +++ b/src/platform/STM32/sdio_f4xx.c @@ -1359,7 +1359,7 @@ SD_Error_t SD_GetCardStatus(SD_CardStatus_t* pCardStatus) static SD_Error_t SD_PowerON(void) { SD_Error_t ErrorState; - uint32_t Response; + uint32_t Response = 0; // Avoid (invalid) maybe-unitialized compiler error. uint32_t Count; uint32_t ValidVoltage; uint32_t SD_Type;