aboutsummaryrefslogtreecommitdiff
path: root/hw/serial.c
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-04-07 21:01:17 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2004-04-07 21:01:17 +0000
commit52302d72748bd6c574bf2fd7c8be7f19d12db467 (patch)
treeb4336ae53d9cf06248d2cfc682c83d36ed1aec35 /hw/serial.c
parent333190eb9790ad585a8c18cbb380c07db20f35b4 (diff)
downloadqemu-52302d72748bd6c574bf2fd7c8be7f19d12db467.zip
qemu-52302d72748bd6c574bf2fd7c8be7f19d12db467.tar.gz
qemu-52302d72748bd6c574bf2fd7c8be7f19d12db467.tar.bz2
fix the no device case
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@715 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/serial.c')
-rw-r--r--hw/serial.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/hw/serial.c b/hw/serial.c
index c409659..3cf43f4 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -123,10 +123,12 @@ static void serial_ioport_write(void *opaque, uint32_t addr, uint32_t val)
s->lsr &= ~UART_LSR_THRE;
serial_update_irq(s);
- ch = val;
- do {
- ret = write(s->out_fd, &ch, 1);
- } while (ret != 1);
+ if (s->out_fd >= 0) {
+ ch = val;
+ do {
+ ret = write(s->out_fd, &ch, 1);
+ } while (ret != 1);
+ }
s->thr_ipending = 1;
s->lsr |= UART_LSR_THRE;
s->lsr |= UART_LSR_TEMT;
@@ -267,7 +269,10 @@ SerialState *serial_init(int base, int irq, int fd)
register_ioport_write(base, 8, 1, serial_ioport_write, s);
register_ioport_read(base, 8, 1, serial_ioport_read, s);
- if (fd != 0) {
+ if (fd < 0) {
+ /* no associated device */
+ s->out_fd = -1;
+ } else if (fd != 0) {
qemu_add_fd_read_handler(fd, serial_can_receive1, serial_receive1, s);
s->out_fd = fd;
} else {