From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40279) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zguc8-0002xt-F7 for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:06:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zguc0-00080O-NR for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:06:36 -0400 Received: from mx4-phx2.redhat.com ([209.132.183.25]:54473) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zguc0-0007zZ-Gv for qemu-devel@nongnu.org; Tue, 29 Sep 2015 09:06:28 -0400 Date: Tue, 29 Sep 2015 09:06:17 -0400 (EDT) From: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Message-ID: <1225326230.19668152.1443531977461.JavaMail.zimbra@redhat.com> In-Reply-To: <560A8C50.3020307@huawei.com> References: <1443094669-4144-1-git-send-email-marcandre.lureau@redhat.com> <1443094669-4144-21-git-send-email-marcandre.lureau@redhat.com> <560A8C50.3020307@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v4 20/47] ivshmem: simplify a bit the code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Claudio Fontana Cc: drjones@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com, pbonzini@redhat.com, marcandre lureau , cam@cs.ualberta.ca Hi ----- Original Message ----- > On 24.09.2015 13:37, marcandre.lureau@redhat.com wrote: > > From: Marc-Andr=C3=A9 Lureau > >=20 > > Use some more explicit variables to simplify the code. > >=20 > > nth_eventfd variable is the current eventfd to be manipulated. >=20 > "the new_eventfd variable is the new eventfd to be manipulated". > Although after the name change it is so obvious that maybe it could be > removed from the commit message? sure, would you give the reviewed-by with (or without) that change? =20 > >=20 > > Signed-off-by: Marc-Andr=C3=A9 Lureau > > --- > > hw/misc/ivshmem.c | 28 ++++++++++++++-------------- > > 1 file changed, 14 insertions(+), 14 deletions(-) > >=20 > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > > index 63bcf6c..c59d9ed 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 =3D opaque; > > int incoming_fd; > > - int guest_max_eventfd; > > + int new_eventfd; > > long incoming_posn; > > Error *err =3D NULL; > > + Peer *peer; > > =20 > > 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) > > } > > } > > =20 > > + peer =3D &s->peers[incoming_posn]; > > + > > if (incoming_fd =3D=3D -1) { > > /* if posn is positive and unseen before then this is our posn= */ > > if (incoming_posn >=3D 0 && s->vm_id =3D=3D -1) { > > @@ -564,27 +567,24 @@ static void ivshmem_read(void *opaque, const uint= 8_t > > *buf, int size) > > return; > > } > > =20 > > - /* each guest has an array of eventfds, and we keep track of how m= any > > - * guests for each VM */ > > - guest_max_eventfd =3D 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 =3D peer->nb_eventfds++; > > =20 > > /* this is an eventfd for a particular guest VM */ > > IVSHMEM_DPRINTF("eventfds[%ld][%d] =3D %d\n", incoming_posn, > > - guest_max_eventfd, incoming_fd); > > - > > event_notifier_init_fd(&s->peers[incoming_posn].eventfds[guest_max_even= tfd], > > - 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); > > =20 > > if (incoming_posn =3D=3D s->vm_id) { > > - s->eventfd_chr[guest_max_eventfd] =3D create_eventfd_chr_devic= e(s, > > - &s->peers[s->vm_id].eventfds[guest_max_eventfd], > > - guest_max_eventfd); > > + s->eventfd_chr[new_eventfd] =3D create_eventfd_chr_device(s, > > + &s->peers[s->vm_id].eventfds[new_eventfd], > > + new_eventfd); > > } > > =20 > > if (ivshmem_has_feature(s, IVSHMEM_IOEVENTFD)) { > > - ivshmem_add_eventfd(s, incoming_posn, guest_max_eventfd); > > + ivshmem_add_eventfd(s, incoming_posn, new_eventfd); > > } > > } > > =20 > >=20 >=20 >=20