Skip to content

Commit e4e5e7a

Browse files
tpamborkartben
authored andcommitted
drivers: uart: emul: Fix uninitialized variable errors
Fix compiler errors about variables potentially being used uninitialized. These are false positives, as the compiler is confused by the K_SPINLOCK() macro. Explicit initialization avoids these errors. Signed-off-by: Tim Pambor <[email protected]>
1 parent d459853 commit e4e5e7a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/serial/uart_emul.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ static int uart_emul_config_get(const struct device *dev, struct uart_config *cf
201201
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
202202
static int uart_emul_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
203203
{
204-
int ret;
204+
int ret = 0;
205205
struct uart_emul_data *data = dev->data;
206206
const struct uart_emul_config *config = dev->config;
207207
uint32_t put_size = MIN(config->latch_buffer_size, size);
@@ -223,7 +223,7 @@ static int uart_emul_fifo_read(const struct device *dev, uint8_t *rx_data, int s
223223
{
224224
struct uart_emul_data *data = dev->data;
225225
const struct uart_emul_config *config = dev->config;
226-
uint32_t bytes_to_read;
226+
uint32_t bytes_to_read = 0;
227227

228228
K_SPINLOCK(&data->rx_lock) {
229229
bytes_to_read = MIN(config->latch_buffer_size, ring_buf_size_get(data->rx_rb));
@@ -312,7 +312,7 @@ static int uart_emul_irq_is_pending(const struct device *dev)
312312

313313
static void uart_emul_irq_tx_enable(const struct device *dev)
314314
{
315-
bool submit_irq_work;
315+
bool submit_irq_work = false;
316316
struct uart_emul_data *const data = dev->data;
317317

318318
K_SPINLOCK(&data->tx_lock) {
@@ -327,7 +327,7 @@ static void uart_emul_irq_tx_enable(const struct device *dev)
327327

328328
static void uart_emul_irq_rx_enable(const struct device *dev)
329329
{
330-
bool submit_irq_work;
330+
bool submit_irq_work = false;
331331
struct uart_emul_data *const data = dev->data;
332332

333333
K_SPINLOCK(&data->rx_lock) {
@@ -919,10 +919,10 @@ void uart_emul_callback_tx_data_ready_set(const struct device *dev,
919919
uint32_t uart_emul_put_rx_data(const struct device *dev, const uint8_t *data, size_t size)
920920
{
921921
struct uart_emul_data *drv_data = dev->data;
922-
uint32_t count;
923-
__unused bool empty;
924-
__unused bool irq_en;
925-
__unused bool rx_en;
922+
uint32_t count = 0;
923+
__unused bool empty = false;
924+
__unused bool irq_en = false;
925+
__unused bool rx_en = false;
926926

927927
K_SPINLOCK(&drv_data->rx_lock) {
928928
count = ring_buf_put(drv_data->rx_rb, data, size);

0 commit comments

Comments
 (0)