From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj0kK-0002EF-Hg for qemu-devel@nongnu.org; Mon, 05 Oct 2015 04:03:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zj0kE-0001aC-Dk for qemu-devel@nongnu.org; Mon, 05 Oct 2015 04:03:44 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:24739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zj0kE-0001XJ-5P for qemu-devel@nongnu.org; Mon, 05 Oct 2015 04:03:38 -0400 References: <1443812991-17356-1-git-send-email-marcandre.lureau@redhat.com> <1443812991-17356-21-git-send-email-marcandre.lureau@redhat.com> From: Claudio Fontana Message-ID: <56122ECF.5040507@huawei.com> Date: Mon, 5 Oct 2015 10:03:27 +0200 MIME-Version: 1.0 In-Reply-To: <1443812991-17356-21-git-send-email-marcandre.lureau@redhat.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v5 20/48] ivshmem: simplify a bit the code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com, qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, cam@cs.ualberta.ca, stefanha@redhat.com On 02.10.2015 21:09, marcandre.lureau@redhat.com wrote: > From: Marc-André Lureau > > Use some more explicit variables to simplify the code. > > Signed-off-by: Marc-André Lureau Reviewed-by: Claudio Fontana > --- > hw/misc/ivshmem.c | 28 ++++++++++++++-------------- > 1 file changed, 14 insertions(+), 14 deletions(-) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index 6ee4881..c054e52 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -488,9 +488,10 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) > { > IVShmemState *s = opaque; > int incoming_fd; > - int guest_max_eventfd; > + int new_eventfd; > long incoming_posn; > Error *err = NULL; > + Peer *peer; > > if (!fifo_update_and_get(s, buf, size, > &incoming_posn, sizeof(incoming_posn))) { > @@ -517,6 +518,8 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) > } > } > > + peer = &s->peers[incoming_posn]; > + > if (incoming_fd == -1) { > /* if posn is positive and unseen before then this is our posn*/ > if (incoming_posn >= 0 && s->vm_id == -1) { > @@ -564,27 +567,24 @@ static void ivshmem_read(void *opaque, const uint8_t *buf, int size) > return; > } > > - /* each guest has an array of eventfds, and we keep track of how many > - * guests for each VM */ > - guest_max_eventfd = s->peers[incoming_posn].nb_eventfds; > + /* each peer has an associated array of eventfds, and we keep > + * track of how many eventfds received so far */ > + /* get a new eventfd: */ > + new_eventfd = peer->nb_eventfds++; > > /* this is an eventfd for a particular guest VM */ > IVSHMEM_DPRINTF("eventfds[%ld][%d] = %d\n", incoming_posn, > - guest_max_eventfd, incoming_fd); > - event_notifier_init_fd(&s->peers[incoming_posn].eventfds[guest_max_eventfd], > - incoming_fd); > - > - /* increment count for particular guest */ > - s->peers[incoming_posn].nb_eventfds++; > + new_eventfd, incoming_fd); > + event_notifier_init_fd(&peer->eventfds[new_eventfd], incoming_fd); > > if (incoming_posn == s->vm_id) { > - s->eventfd_chr[guest_max_eventfd] = create_eventfd_chr_device(s, > - &s->peers[s->vm_id].eventfds[guest_max_eventfd], > - guest_max_eventfd); > + s->eventfd_chr[new_eventfd] = create_eventfd_chr_device(s, > + &s->peers[s->vm_id].eventfds[new_eventfd], > + new_eventfd); > } > > if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { > - ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd); > + ivshmem_add_eventfd(s, incoming_posn, new_eventfd); > } > } > > -- Claudio Fontana Server Virtualization Architect Huawei Technologies Duesseldorf GmbH Riesstraße 25 - 80992 München