Skip to content

Commit 7455b89

Browse files
authored
Merge pull request #11280 from Tharazi97/stm_spi_api_memset_fill_truncated
Tweak stm_spi_api Coverity warning.
2 parents 1182d1e + 5c9daa3 commit 7455b89

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

targets/TARGET_STM/stm_spi_api.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,9 +494,8 @@ int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
494494
struct spi_s *spiobj = SPI_S(obj);
495495
SPI_HandleTypeDef *handle = &(spiobj->handle);
496496
int total = (tx_length > rx_length) ? tx_length : rx_length;
497-
int i = 0;
498497
if (handle->Init.Direction == SPI_DIRECTION_2LINES) {
499-
for (i = 0; i < total; i++) {
498+
for (int i = 0; i < total; i++) {
500499
char out = (i < tx_length) ? tx_buffer[i] : write_fill;
501500
char in = spi_master_write(obj, out);
502501
if (i < rx_length) {
@@ -661,7 +660,7 @@ static int spi_master_start_asynch_transfer(spi_t *obj, transfer_type_t transfer
661660
case SPI_TRANSFER_TYPE_RX:
662661
// the receive function also "transmits" the receive buffer so in order
663662
// to guarantee that 0xff is on the line, we explicitly memset it here
664-
memset(rx, SPI_FILL_WORD, length);
663+
memset(rx, SPI_FILL_CHAR, length);
665664
rc = HAL_SPI_Receive_IT(handle, (uint8_t *)rx, words);
666665
break;
667666
default:

0 commit comments

Comments
 (0)