All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>,
	Prasad J Pandit <ppandit@redhat.com>
Cc: "Philippe Mathieu-Daudé" <philmd@redhat.com>,
	qemu-devel@nongnu.org,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>
Subject: [Qemu-devel] [PATCH v2 03/11] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc
Date: Fri, 12 Oct 2018 02:22:09 +0200	[thread overview]
Message-ID: <20181012002217.2864-4-philmd@redhat.com> (raw)
In-Reply-To: <20181012002217.2864-1-philmd@redhat.com>

IOWatchPoll::fd_can_read() simply returns a boolean value.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 chardev/char-fd.c         | 4 ++--
 chardev/char-io.c         | 4 ++--
 chardev/char-pty.c        | 4 ++--
 chardev/char-socket.c     | 6 +++---
 chardev/char-udp.c        | 4 ++--
 include/chardev/char-io.h | 2 +-
 6 files changed, 12 insertions(+), 12 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, GIOCondition cond, void *opaque)
     return TRUE;
 }
 
-static int fd_chr_read_poll(void *opaque)
+static gboolean fd_chr_read_poll(void *opaque)
 {
     Chardev *chr = CHARDEV(opaque);
     FDChardev *s = FD_CHARDEV(opaque);
 
     s->max_size = qemu_chr_be_can_write(chr);
-    return s->max_size;
+    return s->max_size > 0;
 }
 
 static GSource *fd_chr_add_watch(Chardev *chr, GIOCondition cond)
diff --git a/chardev/char-io.c b/chardev/char-io.c
index 8ced184160..a264d4e7fd 100644
--- a/chardev/char-io.c
+++ b/chardev/char-io.c
@@ -30,7 +30,7 @@ typedef struct IOWatchPoll {
     QIOChannel *ioc;
     GSource *src;
 
-    IOCanReadHandler *fd_can_read;
+    GSourceFunc fd_can_read;
     GSourceFunc fd_read;
     void *opaque;
 } IOWatchPoll;
@@ -76,7 +76,7 @@ static GSourceFuncs io_watch_poll_funcs = {
 
 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 e8d9a53476..626ca30cb3 100644
--- a/chardev/char-pty.c
+++ b/chardev/char-pty.c
@@ -148,13 +148,13 @@ static GSource *pty_chr_add_watch(Chardev *chr, GIOCondition cond)
     return qio_channel_create_watch(s->ioc, cond);
 }
 
-static int pty_chr_read_poll(void *opaque)
+static gboolean pty_chr_read_poll(void *opaque)
 {
     Chardev *chr = CHARDEV(opaque);
     PtyChardev *s = PTY_CHARDEV(opaque);
 
     s->read_bytes = qemu_chr_be_can_write(chr);
-    return s->read_bytes;
+    return s->read_bytes > 0;
 }
 
 static gboolean pty_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index a75b46d9fe..76cc3c48b0 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -120,7 +120,7 @@ static void tcp_chr_accept(QIONetListener *listener,
                            QIOChannelSocket *cioc,
                            void *opaque);
 
-static int tcp_chr_read_poll(void *opaque);
+static gboolean tcp_chr_read_poll(void *opaque);
 static void tcp_chr_disconnect(Chardev *chr);
 
 /* Called with chr_write_lock held.  */
@@ -157,7 +157,7 @@ static int tcp_chr_write(Chardev *chr, const uint8_t *buf, int len)
     }
 }
 
-static int tcp_chr_read_poll(void *opaque)
+static gboolean tcp_chr_read_poll(void *opaque)
 {
     Chardev *chr = CHARDEV(opaque);
     SocketChardev *s = SOCKET_CHARDEV(opaque);
@@ -165,7 +165,7 @@ static int tcp_chr_read_poll(void *opaque)
         return 0;
     }
     s->max_size = qemu_chr_be_can_write(chr);
-    return s->max_size;
+    return s->max_size > 0;
 }
 
 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)
     }
 }
 
-static int udp_chr_read_poll(void *opaque)
+static gboolean udp_chr_read_poll(void *opaque)
 {
     Chardev *chr = CHARDEV(opaque);
     UdpChardev *s = UDP_CHARDEV(opaque);
@@ -77,7 +77,7 @@ static int udp_chr_read_poll(void *opaque)
      */
     udp_chr_flush_buffer(s);
 
-    return s->max_size;
+    return s->max_size > 0;
 }
 
 static gboolean udp_chr_read(QIOChannel *chan, GIOCondition cond, void *opaque)
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);
-- 
2.17.1

  parent reply	other threads:[~2018-10-12  0:22 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-12  0:22 [Qemu-devel] [PATCH v2 00/11] chardev: Convert IO handlers to use unsigned type Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 01/11] hw/ipmi: Remove unnecessary declarations Philippe Mathieu-Daudé
2018-10-12  0:51   ` Corey Minyard
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 02/11] target/xtensa: " Philippe Mathieu-Daudé
2018-10-12  0:22 ` Philippe Mathieu-Daudé [this message]
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 04/11] chardev: Assert backend's chr_can_read() is positive Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 05/11] chardev: Let chr_sync_read() use unsigned type Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 06/11] chardev: Let chr_write " Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 07/11] chardev: Let IOReadHandler " Philippe Mathieu-Daudé
2018-10-12  0:22   ` Philippe Mathieu-Daudé
2018-10-12  0:22   ` Philippe Mathieu-Daudé
2021-01-22 11:26   ` [Qemu-devel] " Richard Purdie
2021-01-22 11:52     ` P J P
2021-01-22 13:55       ` Philippe Mathieu-Daudé
2021-01-22 15:25         ` Richard Purdie
2018-10-12  0:22 ` [Qemu-arm] [PATCH v2 08/11] chardev: Let IOCanReadHandler " Philippe Mathieu-Daudé
2018-10-12  0:22   ` [Qemu-devel] " Philippe Mathieu-Daudé
2018-10-12  0:22   ` Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 09/11] chardev: Let qemu_chr_fe_* " Philippe Mathieu-Daudé
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 10/11] chardev: Let qemu_chr_be_* " Philippe Mathieu-Daudé
2018-10-12  6:43   ` Pavel Dovgalyuk
2018-10-12  0:22 ` [Qemu-devel] [PATCH v2 11/11] chardev: FDChardev::max_size be unsigned Philippe Mathieu-Daudé
2018-10-12  8:05   ` Paolo Bonzini
2018-10-12  8:20 ` [Qemu-devel] [PATCH v2 00/11] chardev: Convert IO handlers to use unsigned type Daniel P. Berrangé
2025-02-20 10:07   ` Philippe Mathieu-Daudé
2025-02-20 10:09     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181012002217.2864-4-philmd@redhat.com \
    --to=philmd@redhat.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=ppandit@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.