From nobody Sun Nov 9 14:46:33 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1550626001471728.6967521610953; Tue, 19 Feb 2019 17:26:41 -0800 (PST) Received: from localhost ([127.0.0.1]:57659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGei-0000yU-CZ for importer@patchew.org; Tue, 19 Feb 2019 20:26:36 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGR3-00059h-Iv for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:12:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGJ0-0001j3-VI for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:04:12 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40252) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gwGJ0-0001O3-G1; Tue, 19 Feb 2019 20:04:10 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4032080472; Wed, 20 Feb 2019 01:03:12 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.205.222]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 565F91001DE2; Wed, 20 Feb 2019 01:02:55 +0000 (UTC) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Date: Wed, 20 Feb 2019 02:02:08 +0100 Message-Id: <20190220010232.18731-2-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Wed, 20 Feb 2019 01:03:12 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard , Stefano Stabellini , Samuel Thibault , Li Zhijian , Amit Shah , "Michael S. Tsirkin" , Jason Wang , Cornelia Huck , Halil Pasic , Christian Borntraeger , qemu-s390x@nongnu.org, Paul Durrant , qemu-ppc@nongnu.org, Gerd Hoffmann , Pavel Dovgalyuk , Zhang Chen , Anthony Perard , xen-devel@lists.xenproject.org, Stefan Berger , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" IOWatchPoll::fd_can_read() really is a GSourceFunc type, it simply returns a boolean value. Update the backends to return a boolean, whether there is data to read from the source or not. Suggested-by: Paolo Bonzini Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Marc-Andr=C3=A9 Lureau --- chardev/char-fd.c | 4 ++-- chardev/char-io.c | 6 +++--- chardev/char-pty.c | 4 ++-- chardev/char-socket.c | 6 +++--- chardev/char-udp.c | 4 ++-- include/chardev/char-io.h | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/chardev/char-fd.c b/chardev/char-fd.c index 2c9b2ce567..2421d8e216 100644 --- a/chardev/char-fd.c +++ b/chardev/char-fd.c @@ -69,13 +69,13 @@ static gboolean fd_chr_read(QIOChannel *chan, GIOCondit= ion cond, void *opaque) return TRUE; } =20 -static int fd_chr_read_poll(void *opaque) +static gboolean fd_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); FDChardev *s =3D FD_CHARDEV(opaque); =20 s->max_size =3D qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } =20 static GSource *fd_chr_add_watch(Chardev *chr, GIOCondition cond) diff --git a/chardev/char-io.c b/chardev/char-io.c index 8ced184160..2c1c69098e 100644 --- a/chardev/char-io.c +++ b/chardev/char-io.c @@ -30,7 +30,7 @@ typedef struct IOWatchPoll { QIOChannel *ioc; GSource *src; =20 - IOCanReadHandler *fd_can_read; + GSourceFunc fd_can_read; GSourceFunc fd_read; void *opaque; } IOWatchPoll; @@ -44,7 +44,7 @@ static gboolean io_watch_poll_prepare(GSource *source, gint *timeout) { IOWatchPoll *iwp =3D io_watch_poll_from_source(source); - bool now_active =3D iwp->fd_can_read(iwp->opaque) > 0; + bool now_active =3D iwp->fd_can_read(iwp->opaque); bool was_active =3D iwp->src !=3D NULL; if (was_active =3D=3D now_active) { return FALSE; @@ -76,7 +76,7 @@ static GSourceFuncs io_watch_poll_funcs =3D { =20 GSource *io_add_watch_poll(Chardev *chr, QIOChannel *ioc, - IOCanReadHandler *fd_can_read, + GSourceFunc fd_can_read, QIOChannelFunc fd_read, gpointer user_data, GMainContext *context) diff --git a/chardev/char-pty.c b/chardev/char-pty.c index b034332edd..7777f6ddef 100644 --- a/chardev/char-pty.c +++ b/chardev/char-pty.c @@ -119,13 +119,13 @@ static GSource *pty_chr_add_watch(Chardev *chr, GIOCo= ndition cond) return qio_channel_create_watch(s->ioc, cond); } =20 -static int pty_chr_read_poll(void *opaque) +static gboolean pty_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); PtyChardev *s =3D PTY_CHARDEV(opaque); =20 s->read_bytes =3D qemu_chr_be_can_write(chr); - return s->read_bytes; + return s->read_bytes > 0; } =20 static gboolean pty_chr_read(QIOChannel *chan, GIOCondition cond, void *op= aque) diff --git a/chardev/char-socket.c b/chardev/char-socket.c index 4fcdd8aedd..262a59b64f 100644 --- a/chardev/char-socket.c +++ b/chardev/char-socket.c @@ -147,7 +147,7 @@ static void tcp_chr_accept(QIONetListener *listener, QIOChannelSocket *cioc, void *opaque); =20 -static int tcp_chr_read_poll(void *opaque); +static gboolean tcp_chr_read_poll(void *opaque); static void tcp_chr_disconnect(Chardev *chr); =20 /* Called with chr_write_lock held. */ @@ -184,7 +184,7 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *b= uf, int len) } } =20 -static int tcp_chr_read_poll(void *opaque) +static gboolean tcp_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); SocketChardev *s =3D SOCKET_CHARDEV(opaque); @@ -192,7 +192,7 @@ static int tcp_chr_read_poll(void *opaque) return 0; } s->max_size =3D qemu_chr_be_can_write(chr); - return s->max_size; + return s->max_size > 0; } =20 static void tcp_chr_process_IAC_bytes(Chardev *chr, diff --git a/chardev/char-udp.c b/chardev/char-udp.c index 097a2f0f42..b6e399e983 100644 --- a/chardev/char-udp.c +++ b/chardev/char-udp.c @@ -65,7 +65,7 @@ static void udp_chr_flush_buffer(UdpChardev *s) } } =20 -static int udp_chr_read_poll(void *opaque) +static gboolean udp_chr_read_poll(void *opaque) { Chardev *chr =3D CHARDEV(opaque); UdpChardev *s =3D UDP_CHARDEV(opaque); @@ -77,7 +77,7 @@ static int udp_chr_read_poll(void *opaque) */ udp_chr_flush_buffer(s); =20 - return s->max_size; + return s->max_size > 0; } =20 static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *op= aque) diff --git a/include/chardev/char-io.h b/include/chardev/char-io.h index 9638da5100..a173874538 100644 --- a/include/chardev/char-io.h +++ b/include/chardev/char-io.h @@ -31,7 +31,7 @@ /* Can only be used for read */ GSource *io_add_watch_poll(Chardev *chr, QIOChannel *ioc, - IOCanReadHandler *fd_can_read, + GSourceFunc fd_can_read, QIOChannelFunc fd_read, gpointer user_data, GMainContext *context); --=20 2.20.1