diff options
| author | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-20 15:02:40 +0200 |
|---|---|---|
| committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-06-29 14:03:47 +0200 |
| commit | 6f1de6b70d857d5e316ae6fd908f52818b827b08 (patch) | |
| tree | 1a0c8e85a0d1046373cdad821e9dda0025046be9 /hw/char/cadence_uart.c | |
| parent | b0585e7e07982daa578c3bfef7f6843c89f110a8 (diff) | |
| download | focaccia-qemu-6f1de6b70d857d5e316ae6fd908f52818b827b08.tar.gz focaccia-qemu-6f1de6b70d857d5e316ae6fd908f52818b827b08.zip | |
char: change qemu_chr_fe_add_watch to return unsigned
g_source_attach can return any value between 1 and UINT_MAX if you let QEMU run long enough. However, qemu_chr_fe_add_watch can also return a negative errno value when the device is disconnected or does not support chr_add_watch. Change it to return zero to avoid overloading these values. Fix the cadence_uart which asserts in this case (easily obtained with "-serial pty"). Tested-by: Bret Ketchum <bcketchum@gmail.com> Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/char/cadence_uart.c')
| -rw-r--r-- | hw/char/cadence_uart.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/hw/char/cadence_uart.c b/hw/char/cadence_uart.c index c856fc30b2..65179fa500 100644 --- a/hw/char/cadence_uart.c +++ b/hw/char/cadence_uart.c @@ -292,9 +292,12 @@ static gboolean cadence_uart_xmit(GIOChannel *chan, GIOCondition cond, memmove(s->tx_fifo, s->tx_fifo + ret, s->tx_count); if (s->tx_count) { - int r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, - cadence_uart_xmit, s); - assert(r); + guint r = qemu_chr_fe_add_watch(s->chr, G_IO_OUT|G_IO_HUP, + cadence_uart_xmit, s); + if (!r) { + s->tx_count = 0; + return FALSE; + } } uart_update_status(s); |