From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:47725) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf6M9-0008A6-Jo for qemu-devel@nongnu.org; Sun, 02 Dec 2012 05:01:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tf6M8-0002tC-MT for qemu-devel@nongnu.org; Sun, 02 Dec 2012 05:01:01 -0500 Received: from mx4-phx2.redhat.com ([209.132.183.25]:35072) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tf6M8-0002t3-Ef for qemu-devel@nongnu.org; Sun, 02 Dec 2012 05:01:00 -0500 Date: Sun, 2 Dec 2012 05:00:35 -0500 (EST) From: Alon Levy Message-ID: <2017046076.41349263.1354442435217.JavaMail.root@redhat.com> In-Reply-To: <1354281947-20227-3-git-send-email-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 2/6] spice-qemu-char: write to chardev whatever amount it can read List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?utf-8?Q?Marc-Andr=C3=A9?= Lureau Cc: qemu-devel@nongnu.org, spice-devel@lists.freedesktop.org, kraxel@redhat.com, =?utf-8?Q?Marc-Andr=C3=A9?= Lureau > The current code waits until the chardev can read MIN(len, VMC_MAX) > But some chardev may never reach than amount, in fact some of them > will only ever accept write of 1. Fix the min computation and remove > the VMC_MAX constant. Looks good to me. >=20 > Signed-off-by: Marc-Andr=C3=A9 Lureau > --- > spice-qemu-char.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) >=20 > diff --git a/spice-qemu-char.c b/spice-qemu-char.c > index 09aa22d..665efd3 100644 > --- a/spice-qemu-char.c > +++ b/spice-qemu-char.c > @@ -14,8 +14,6 @@ > } > \ > } while (0) > =20 > -#define VMC_MAX_HOST_WRITE 2048 > - > typedef struct SpiceCharDriver { > CharDriverState* chr; > SpiceCharDeviceInstance sin; > @@ -35,8 +33,8 @@ static int vmc_write(SpiceCharDeviceInstance *sin, > const uint8_t *buf, int len) > uint8_t* p =3D (uint8_t*)buf; > =20 > while (len > 0) { > - last_out =3D MIN(len, VMC_MAX_HOST_WRITE); > - if (qemu_chr_be_can_write(scd->chr) < last_out) { > + last_out =3D MIN(len, qemu_chr_be_can_write(scd->chr)); > + if (last_out <=3D 0) { > break; > } > qemu_chr_be_write(scd->chr, p, last_out); > -- > 1.7.11.7 >=20 >=20 >=20