* [PATCH v2 9/9] hw/char: Simplify when qemu_chr_fe_write() could not write [not found] <20251022150743.78183-1-philmd@linaro.org> @ 2025-10-22 15:07 ` Philippe Mathieu-Daudé 2025-10-28 14:07 ` Marc-André Lureau 0 siblings, 1 reply; 2+ messages in thread From: Philippe Mathieu-Daudé @ 2025-10-22 15:07 UTC (permalink / raw) To: qemu-devel Cc: Peter Maydell, Alex Bennée, Paolo Bonzini, Marc-André Lureau, Philippe Mathieu-Daudé, Edgar E. Iglesias, Alistair Francis, Palmer Dabbelt, qemu-arm, qemu-riscv If no chars were written, avoid to access the FIFO. Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> --- hw/char/cadence_uart.c | 2 +- hw/char/ibex_uart.c | 2 +- hw/char/sifive_uart.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index 0dfa356b6d0..8908ebbe34a 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -316,7 +316,7 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count); - if (ret >= 0) { + if (ret > 0) { s->tx_count -= ret; memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count); } diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c index d6f0d18c777..b7843c7a741 100644 --- a/hw/char/ibex_uart.c +++ b/hw/char/ibex_uart.c @@ -161,7 +161,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond, ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level); - if (ret >= 0) { + if (ret > 0) { s->tx_level -= ret; memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_level); } diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c index e7357d585a1..e5b381425a9 100644 --- a/hw/char/sifive_uart.c +++ b/hw/char/sifive_uart.c @@ -83,7 +83,7 @@ static gboolean sifive_uart_xmit(void *do_not_use, GIOCondition cond, fifo8_num_used(&s->tx_fifo), &numptr); ret = qemu_chr_fe_write(&s->chr, characters, numptr); - if (ret >= 0) { + if (ret > 0) { /* We wrote the data, actually pop the fifo */ fifo8_pop_bufptr(&s->tx_fifo, ret, NULL); } -- 2.51.0 ^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 9/9] hw/char: Simplify when qemu_chr_fe_write() could not write 2025-10-22 15:07 ` [PATCH v2 9/9] hw/char: Simplify when qemu_chr_fe_write() could not write Philippe Mathieu-Daudé @ 2025-10-28 14:07 ` Marc-André Lureau 0 siblings, 0 replies; 2+ messages in thread From: Marc-André Lureau @ 2025-10-28 14:07 UTC (permalink / raw) To: Philippe Mathieu-Daudé Cc: qemu-devel, Peter Maydell, Alex Bennée, Paolo Bonzini, Edgar E. Iglesias, Alistair Francis, Palmer Dabbelt, qemu-arm, qemu-riscv On Wed, Oct 22, 2025 at 7:10 PM Philippe Mathieu-Daudé <philmd@linaro.org> wrote: > > If no chars were written, avoid to access the FIFO. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/char/cadence_uart.c | 2 +- > hw/char/ibex_uart.c | 2 +- > hw/char/sifive_uart.c | 2 +- > 3 files changed, 3 insertions(+), 3 deletions(-) > > diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c > index 0dfa356b6d0..8908ebbe34a 100644 > --- a/hw/char/cadence_uart.c > +++ b/hw/char/cadence_uart.c > @@ -316,7 +316,7 @@ static gboolean cadence_uart_xmit(void *do_not_use, GIOCondition cond, > > ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_count); > > - if (ret >= 0) { > + if (ret > 0) { > s->tx_count -= ret; > memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count); > } > diff --git a/hw/char/ibex_uart.c b/hw/char/ibex_uart.c > index d6f0d18c777..b7843c7a741 100644 > --- a/hw/char/ibex_uart.c > +++ b/hw/char/ibex_uart.c > @@ -161,7 +161,7 @@ static gboolean ibex_uart_xmit(void *do_not_use, GIOCondition cond, > > ret = qemu_chr_fe_write(&s->chr, s->tx_fifo, s->tx_level); > > - if (ret >= 0) { > + if (ret > 0) { > s->tx_level -= ret; > memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_level); > } > diff --git a/hw/char/sifive_uart.c b/hw/char/sifive_uart.c > index e7357d585a1..e5b381425a9 100644 > --- a/hw/char/sifive_uart.c > +++ b/hw/char/sifive_uart.c > @@ -83,7 +83,7 @@ static gboolean sifive_uart_xmit(void *do_not_use, GIOCondition cond, > fifo8_num_used(&s->tx_fifo), &numptr); > ret = qemu_chr_fe_write(&s->chr, characters, numptr); > > - if (ret >= 0) { > + if (ret > 0) { > /* We wrote the data, actually pop the fifo */ > fifo8_pop_bufptr(&s->tx_fifo, ret, NULL); > } > -- > 2.51.0 > > -- Marc-André Lureau ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-10-28 14:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20251022150743.78183-1-philmd@linaro.org>
2025-10-22 15:07 ` [PATCH v2 9/9] hw/char: Simplify when qemu_chr_fe_write() could not write Philippe Mathieu-Daudé
2025-10-28 14:07 ` Marc-André Lureau
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).