From 892de236f336f5cee84a864da2639e7c64998e98 Mon Sep 17 00:00:00 2001 From: Thanos Makatos Date: Tue, 1 Dec 2020 10:17:20 -0500 Subject: drop unnecessary restore_fd Signed-off-by: Thanos Makatos --- lib/irq.c | 14 ++++++-------- lib/libvfio-user.c | 8 +------- 2 files changed, 7 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/irq.c b/lib/irq.c index 9a4beff..426e0ae 100644 --- a/lib/irq.c +++ b/lib/irq.c @@ -171,14 +171,12 @@ irqs_set_data_eventfd(vfu_ctx_t *vfu_ctx, struct vfio_irq_set *irq_set, vfu_ctx->irqs->efds[i] = -1; } - if (data[j] >= 0) { /* TODO IIUC this will always be >= 0? */ - vfu_ctx->irqs->efds[i] = data[j]; - /* - * We've already checked in handle_device_set_irqs that - * nr_fds == irq_set->count. - */ - consume_fd(data, irq_set->count, j); - } + assert(data[j] >= 0); + /* + * We've already checked in handle_device_set_irqs that + * nr_fds == irq_set->count. + */ + vfu_ctx->irqs->efds[i] = consume_fd(data, irq_set->count, j); vfu_log(vfu_ctx, VFU_DBG, "event fd[%d]=%d", i, vfu_ctx->irqs->efds[i]); } diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 2d77555..964091c 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -514,12 +514,6 @@ consume_fd(int *fds, size_t nr_fds, size_t index) return fd; } -void -restore_fd(int *fds, size_t index, int fd) -{ - fds[index] = fd; -} - /* * Handles a DMA map/unmap request. * @@ -576,7 +570,7 @@ handle_dma_map_or_unmap(vfu_ctx_t *vfu_ctx, uint32_t size, bool map, dma_regions[i].offset); if (ret < 0) { if (fd != -1) { - restore_fd(fds, fdi - 1, fd); + close(fd); } vfu_log(vfu_ctx, VFU_INF, "failed to add DMA region %#lx-%#lx offset=%#lx fd=%d: %s", -- cgit v1.1