[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 06/39] ivshmem: remove unnecessary dup()
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH 06/39] ivshmem: remove unnecessary dup() |
Date: |
Fri, 26 Jun 2015 16:49:12 +0200 |
qemu_chr_fe_get_msgfd() transfer ownership, there is no need to dup the fd.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/misc/ivshmem.c | 21 ++++++---------------
1 file changed, 6 insertions(+), 15 deletions(-)
diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
index dd15f0e..fbeb731 100644
--- a/hw/misc/ivshmem.c
+++ b/hw/misc/ivshmem.c
@@ -480,7 +480,7 @@ static bool fifo_update_and_get(IVShmemState *s, const
uint8_t *buf, int size,
static void ivshmem_read(void *opaque, const uint8_t *buf, int size)
{
IVShmemState *s = opaque;
- int incoming_fd, tmp_fd;
+ int incoming_fd;
int guest_max_eventfd;
long incoming_posn;
@@ -495,21 +495,21 @@ static void ivshmem_read(void *opaque, const uint8_t
*buf, int size)
}
/* pick off s->server_chr->msgfd and store it, posn should accompany msg */
- tmp_fd = qemu_chr_fe_get_msgfd(s->server_chr);
- IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, tmp_fd);
+ incoming_fd = qemu_chr_fe_get_msgfd(s->server_chr);
+ IVSHMEM_DPRINTF("posn is %ld, fd is %d\n", incoming_posn, incoming_fd);
/* make sure we have enough space for this guest */
if (incoming_posn >= s->nb_peers) {
if (increase_dynamic_storage(s, incoming_posn) < 0) {
error_report("increase_dynamic_storage() failed");
- if (tmp_fd != -1) {
- close(tmp_fd);
+ if (incoming_fd != -1) {
+ close(incoming_fd);
}
return;
}
}
- if (tmp_fd == -1) {
+ if (incoming_fd == -1) {
/* if posn is positive and unseen before then this is our posn*/
if ((incoming_posn >= 0) &&
(s->peers[incoming_posn].eventfds == NULL)) {
@@ -524,15 +524,6 @@ static void ivshmem_read(void *opaque, const uint8_t *buf,
int size)
}
}
- /* because of the implementation of get_msgfd, we need a dup */
- incoming_fd = dup(tmp_fd);
-
- if (incoming_fd == -1) {
- error_report("could not allocate file descriptor %s", strerror(errno));
- close(tmp_fd);
- return;
- }
-
/* if the position is -1, then it's shared memory region fd */
if (incoming_posn == -1) {
--
2.4.3
- [Qemu-devel] [PATCH 00/39] ivshmem server/client, cleanups & test, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 01/39] char: add qemu_chr_free(), Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 02/39] msix: add VMSTATE_MSIX_TEST, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 04/39] ivshmem: fix number of bytes to push to fifo, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 05/39] ivshmem: factor out the incoming fifo handling, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 03/39] ivhsmem: read do not accept more than sizeof(long), Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 07/39] ivshmem: remove superflous ivshmem_attr field, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 08/39] ivshmem: remove useless doorbell field, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 06/39] ivshmem: remove unnecessary dup(),
Marc-André Lureau <=
- [Qemu-devel] [PATCH 09/39] ivshmem: more qdev conversion, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 10/39] ivshmem: remove last exit(1), Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 11/39] ivshmem: increase_dynamic_storage() improvements, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 13/39] ivshmem: initialize max_peer to -1, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 12/39] ivshmem: remove useless ivshmem_update_irq() val argument, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 14/39] ivshmem: remove max_peer field, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 15/39] ivshmem: improve debug messages, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 16/39] ivshmem: improve error, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 17/39] ivshmem: print error on invalid peer id, Marc-André Lureau, 2015/06/26
- [Qemu-devel] [PATCH 18/39] ivshmem: add a warning if eventfd value is 0, Marc-André Lureau, 2015/06/26