diff options
author | Thanos Makatos <thanos.makatos@nutanix.com> | 2020-12-01 10:17:20 -0500 |
---|---|---|
committer | Thanos <tmakatos@gmail.com> | 2020-12-01 15:41:25 +0000 |
commit | 892de236f336f5cee84a864da2639e7c64998e98 (patch) | |
tree | 30a70bb30028d0a1d8735ee4af17eab17c346fa7 /lib | |
parent | 2bf85d990fd93abd2076438040406fa33b1e1e01 (diff) | |
download | libvfio-user-892de236f336f5cee84a864da2639e7c64998e98.zip libvfio-user-892de236f336f5cee84a864da2639e7c64998e98.tar.gz libvfio-user-892de236f336f5cee84a864da2639e7c64998e98.tar.bz2 |
drop unnecessary restore_fd
Signed-off-by: Thanos Makatos <thanos.makatos@nutanix.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irq.c | 14 | ||||
-rw-r--r-- | lib/libvfio-user.c | 8 |
2 files changed, 7 insertions, 15 deletions
@@ -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", |