避免警告,变量可能未初始化就使用 (#5544)

* 避免警告,变量可能未初始化就使用

* 避免警告,变量可能未初始化就使用

* 避免警告,变化可能未初始化就使用。

* Update bsp/stm32/libraries/HAL_Drivers/drv_usart.c

Co-authored-by: guo <guozhanxin@rt-thread.com>

* Update bsp/stm32/libraries/HAL_Drivers/drv_usart_v2.c

Co-authored-by: guo <guozhanxin@rt-thread.com>

Co-authored-by: guo <guozhanxin@rt-thread.com>
This commit is contained in:
diskwu 2022-01-21 11:06:37 +08:00 committed by GitHub
parent b5de986122
commit 03f46c6694
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -918,6 +918,7 @@ static void stm32_dma_config(struct rt_serial_device *serial, rt_ubase_t flag)
struct stm32_uart *uart; struct stm32_uart *uart;
RT_ASSERT(serial != RT_NULL); RT_ASSERT(serial != RT_NULL);
RT_ASSERT(flag == RT_DEVICE_FLAG_DMA_TX || flag == RT_DEVICE_FLAG_DMA_RX);
uart = rt_container_of(serial, struct stm32_uart, serial); uart = rt_container_of(serial, struct stm32_uart, serial);
if (RT_DEVICE_FLAG_DMA_RX == flag) if (RT_DEVICE_FLAG_DMA_RX == flag)
@ -925,7 +926,7 @@ static void stm32_dma_config(struct rt_serial_device *serial, rt_ubase_t flag)
DMA_Handle = &uart->dma_rx.handle; DMA_Handle = &uart->dma_rx.handle;
dma_config = uart->config->dma_rx; dma_config = uart->config->dma_rx;
} }
else if (RT_DEVICE_FLAG_DMA_TX == flag) else /* RT_DEVICE_FLAG_DMA_TX == flag */
{ {
DMA_Handle = &uart->dma_tx.handle; DMA_Handle = &uart->dma_tx.handle;
dma_config = uart->config->dma_tx; dma_config = uart->config->dma_tx;

View File

@ -959,6 +959,7 @@ static void stm32_dma_config(struct rt_serial_device *serial, rt_ubase_t flag)
struct stm32_uart *uart; struct stm32_uart *uart;
RT_ASSERT(serial != RT_NULL); RT_ASSERT(serial != RT_NULL);
RT_ASSERT(flag == RT_DEVICE_FLAG_DMA_TX || flag == RT_DEVICE_FLAG_DMA_RX);
uart = rt_container_of(serial, struct stm32_uart, serial); uart = rt_container_of(serial, struct stm32_uart, serial);
if (RT_DEVICE_FLAG_DMA_RX == flag) if (RT_DEVICE_FLAG_DMA_RX == flag)
@ -966,7 +967,7 @@ static void stm32_dma_config(struct rt_serial_device *serial, rt_ubase_t flag)
DMA_Handle = &uart->dma_rx.handle; DMA_Handle = &uart->dma_rx.handle;
dma_config = uart->config->dma_rx; dma_config = uart->config->dma_rx;
} }
else if (RT_DEVICE_FLAG_DMA_TX == flag) else /* RT_DEVICE_FLAG_DMA_TX == flag */
{ {
DMA_Handle = &uart->dma_tx.handle; DMA_Handle = &uart->dma_tx.handle;
dma_config = uart->config->dma_tx; dma_config = uart->config->dma_tx;