diff --git a/devicemodel/core/mevent.c b/devicemodel/core/mevent.c index 860e4f2b8..2c3a84886 100644 --- a/devicemodel/core/mevent.c +++ b/devicemodel/core/mevent.c @@ -30,7 +30,6 @@ * Micro event library for FreeBSD, designed for a single i/o thread * using EPOLL, and having events be persistent by default. */ -#include #include #include #include @@ -377,7 +376,6 @@ int mevent_init(void) { epoll_fd = epoll_create1(0); - assert(epoll_fd >= 0); if (epoll_fd >= 0) return 0; @@ -420,7 +418,10 @@ mevent_dispatch(void) * Add internal event handler for the pipe write fd */ pipev = mevent_add(mevent_pipefd[0], EVF_READ, mevent_pipe_read, NULL, NULL, NULL); - assert(pipev != NULL); + if (!pipev) { + fprintf(stderr, "pipefd mevent_add failed\n"); + exit(0); + } for (;;) { int suspend_mode; diff --git a/devicemodel/hw/pci/uart.c b/devicemodel/hw/pci/uart.c index cc76f4940..a0eee6460 100644 --- a/devicemodel/hw/pci/uart.c +++ b/devicemodel/hw/pci/uart.c @@ -60,22 +60,18 @@ static void pci_uart_write(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx, uint64_t offset, int size, uint64_t value) { - assert(baridx == 0); - assert(size == 1); - - uart_write(dev->arg, offset, value); + if (baridx == 0 && size == 1) + uart_write(dev->arg, offset, value); } uint64_t pci_uart_read(struct vmctx *ctx, int vcpu, struct pci_vdev *dev, int baridx, uint64_t offset, int size) { - uint8_t val; + uint8_t val = 0xff; - assert(baridx == 0); - assert(size == 1); - - val = uart_read(dev->arg, offset); + if (baridx == 0 && size == 1) + val = uart_read(dev->arg, offset); return val; } diff --git a/devicemodel/hw/pci/virtio/virtio_console.c b/devicemodel/hw/pci/virtio/virtio_console.c index 7369ca818..733b554ea 100644 --- a/devicemodel/hw/pci/virtio/virtio_console.c +++ b/devicemodel/hw/pci/virtio/virtio_console.c @@ -39,7 +39,6 @@ #include #include #include -#include #include #include #include @@ -272,15 +271,13 @@ virtio_console_add_port(struct virtio_console *console, const char *name, static void virtio_console_control_tx(struct virtio_console_port *port, void *arg, - struct iovec *iov, int niov) + struct iovec *iov, int niov __attribute__((unused))) { struct virtio_console *console; struct virtio_console_port *tmp; struct virtio_console_control resp, *ctrl; int i; - assert(niov == 1); - console = port->console; ctrl = (struct virtio_console_control *)iov->iov_base; @@ -363,8 +360,10 @@ virtio_console_control_send(struct virtio_console *console, return; n = vq_getchain(vq, &idx, &iov, 1, NULL); - - assert(n == 1); + if (n < 1) { + WPRINTF(("vtcon: control_send vq_getchain error %d\n", n)); + return; + } memcpy(iov.iov_base, ctrl, sizeof(struct virtio_console_control)); if (payload != NULL && len > 0) diff --git a/devicemodel/hw/uart_core.c b/devicemodel/hw/uart_core.c index 002e3c90a..d2b6d5024 100644 --- a/devicemodel/hw/uart_core.c +++ b/devicemodel/hw/uart_core.c @@ -29,7 +29,6 @@ #include #include -#include #include #include #include @@ -167,7 +166,9 @@ rxfifo_reset(struct uart_vdev *uart, int size) { struct fifo *fifo; - assert(size <= uart->rxfifo_size); + if (size > uart->rxfifo_size) + size = uart->rxfifo_size; + fifo = &uart->rxfifo; fifo->rindex = 0; fifo->windex = 0; @@ -301,7 +302,6 @@ modem_status(uint8_t mcr) */ msr = MSR_DCD | MSR_DSR; } - assert((msr & MSR_DELTA_MASK) == 0); return msr; } @@ -373,8 +373,6 @@ uart_drain(int fd, enum ev_type ev, void *arg) uart = arg; - assert(ev == EVF_READ); - /* * This routine is called in the context of the mevent thread * to take out the uart lock to protect against concurrent @@ -632,18 +630,17 @@ uart_init(uart_intr_func_t intr_assert, uart_intr_func_t intr_deassert, struct uart_vdev *uart; uart = calloc(1, sizeof(struct uart_vdev) + rxfifo_size); + if (uart) { + uart->arg = arg; + uart->rxfifo_size = rxfifo_size; + uart->intr_assert = intr_assert; + uart->intr_deassert = intr_deassert; + uart->rxfifo.buf = (uint8_t *)(uart + 1); - assert(uart != NULL); + pthread_mutex_init(&uart->mtx, NULL); - uart->arg = arg; - uart->rxfifo_size = rxfifo_size; - uart->intr_assert = intr_assert; - uart->intr_deassert = intr_deassert; - uart->rxfifo.buf = (uint8_t *)(uart + 1); - - pthread_mutex_init(&uart->mtx, NULL); - - uart_reset(uart); + uart_reset(uart); + } return uart; }