From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: qemu-devel@nongnu.org, "Prasad J Pandit" <pjp@fedoraproject.org>,
"Marc-André Lureau" <marcandre.lureau@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>
Cc: "Jason Wang" <jasowang@redhat.com>,
"Anthony Perard" <anthony.perard@citrix.com>,
qemu-ppc@nongnu.org, "Stefan Berger" <stefanb@linux.ibm.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
"Gerd Hoffmann" <kraxel@redhat.com>,
"Zhang Chen" <zhangckid@gmail.com>,
xen-devel@lists.xenproject.org,
"Cornelia Huck" <cohuck@redhat.com>,
"Samuel Thibault" <samuel.thibault@ens-lyon.org>,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Amit Shah" <amit@kernel.org>,
"Li Zhijian" <lizhijian@cn.fujitsu.com>,
"Corey Minyard" <minyard@acm.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Paul Durrant" <paul.durrant@citrix.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
qemu-s390x@nongnu.org,
"Pavel Dovgalyuk" <pavel.dovgaluk@ispras.ru>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [Qemu-devel] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc
Date: Wed, 20 Feb 2019 02:02:08 +0100 [thread overview]
Message-ID: <20190220010232.18731-2-philmd@redhat.com> (raw)
In-Reply-To: <20190220010232.18731-1-philmd@redhat.com>
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 <pbonzini@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
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, 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..2c1c69098e 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;
@@ -44,7 +44,7 @@ static gboolean io_watch_poll_prepare(GSource *source,
gint *timeout)
{
IOWatchPoll *iwp = io_watch_poll_from_source(source);
- bool now_active = iwp->fd_can_read(iwp->opaque) > 0;
+ bool now_active = iwp->fd_can_read(iwp->opaque);
bool was_active = iwp->src != NULL;
if (was_active == now_active) {
return FALSE;
@@ -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 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, 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 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);
-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. */
@@ -184,7 +184,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);
@@ -192,7 +192,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.20.1
next prev parent reply other threads:[~2019-02-20 1:12 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-20 1:02 [Qemu-devel] [PATCH v3 00/25] chardev: Convert qemu_chr_write() to take a size_t argument Philippe Mathieu-Daudé
2019-02-20 1:02 ` Philippe Mathieu-Daudé [this message]
2019-02-20 9:45 ` [Qemu-devel] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 02/25] chardev: Assert IOCanReadHandler can not be negative Philippe Mathieu-Daudé
2019-02-20 10:03 ` Marc-André Lureau
2019-02-20 11:13 ` Philippe Mathieu-Daudé
2019-02-22 0:39 ` Philippe Mathieu-Daudé
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 03/25] chardev/wctablet: Use unsigned type to hold unsigned value Philippe Mathieu-Daudé
2019-02-20 7:32 ` Gerd Hoffmann
2019-02-20 10:17 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 04/25] chardev: Let qemu_chr_be_can_write() return a size_t types Philippe Mathieu-Daudé
2019-02-20 10:40 ` Marc-André Lureau
2019-02-20 11:26 ` Philippe Mathieu-Daudé
2019-02-20 13:28 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 05/25] gdbstub: Use size_t for strlen() return value Philippe Mathieu-Daudé
2019-02-20 10:57 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 06/25] gdbstub: Use size_t to hold GDBState::last_packet_len Philippe Mathieu-Daudé
2019-02-20 10:59 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 07/25] gdbstub: Let put_buffer() use size_t Philippe Mathieu-Daudé
2019-02-20 11:02 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 08/25] ui/gtk: Remove pointless cast Philippe Mathieu-Daudé
2019-02-20 7:32 ` Gerd Hoffmann
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 09/25] vhost-user: Express sizeof with size_t Philippe Mathieu-Daudé
2019-02-20 11:06 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 10/25] usb-redir: Verify usbredirparser_write get called with positive count Philippe Mathieu-Daudé
2019-02-20 7:32 ` Gerd Hoffmann
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 11/25] xen: Let xencons_send() take a 'size' argument Philippe Mathieu-Daudé
2019-02-20 11:07 ` Marc-André Lureau
2019-02-21 9:34 ` Paul Durrant
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 12/25] xen: Let buffer_append() return the size consumed Philippe Mathieu-Daudé
2019-02-20 11:13 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [RFC PATCH v3 13/25] xen: Let buffer_append() return a size_t Philippe Mathieu-Daudé
2019-02-21 9:54 ` Paul Durrant
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 14/25] virtio-serial: Let VirtIOSerialPortClass::have_data() use size_t Philippe Mathieu-Daudé
2019-02-20 11:21 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 15/25] spapr-vty: Let vty_putchars() " Philippe Mathieu-Daudé
2019-02-20 1:39 ` David Gibson
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 16/25] tpm: Use size_t to hold sizes Philippe Mathieu-Daudé
2019-02-20 11:22 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 17/25] net/filter-mirror: Use size_t Philippe Mathieu-Daudé
2019-02-20 11:23 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 18/25] s390x/3270: Let insert_IAC_escape_char() use size_t Philippe Mathieu-Daudé
2019-02-20 9:37 ` Cornelia Huck
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 19/25] s390/ebcdic: Use size_t to iterate over arrays Philippe Mathieu-Daudé
2019-02-20 9:40 ` Cornelia Huck
2019-02-20 11:37 ` Philippe Mathieu-Daudé
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 20/25] s390x/sclp: Use a const variable to improve readability Philippe Mathieu-Daudé
2019-02-20 10:53 ` Cornelia Huck
2019-03-08 19:12 ` Philippe Mathieu-Daudé
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 21/25] s390x/sclp: Use size_t in process_mdb() Philippe Mathieu-Daudé
2019-02-20 10:53 ` Cornelia Huck
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 22/25] s390x/sclp: Let write_console_data() take a size_t Philippe Mathieu-Daudé
2019-02-20 10:54 ` Cornelia Huck
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos Philippe Mathieu-Daudé
2019-02-20 13:36 ` Marc-André Lureau
2019-02-20 13:36 ` Corey Minyard
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 24/25] chardev: Let qemu_chr_fe_write[_all] use size_t type argument Philippe Mathieu-Daudé
2019-02-20 13:44 ` Marc-André Lureau
2019-02-20 1:02 ` [Qemu-devel] [PATCH v3 25/25] chardev: Let qemu_chr_write[_all] use size_t Philippe Mathieu-Daudé
2019-02-20 10:38 ` Daniel P. Berrangé
2019-02-20 10:42 ` Marc-André Lureau
2019-02-20 11:31 ` Philippe Mathieu-Daudé
2019-02-20 10:53 ` [Qemu-devel] [PATCH v3 00/25] chardev: Convert qemu_chr_write() to take a size_t argument Marc-André Lureau
2019-02-20 10:57 ` Cornelia Huck
2019-02-20 11:30 ` Daniel P. Berrangé
2019-02-20 14:20 ` Eric Blake
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=20190220010232.18731-2-philmd@redhat.com \
--to=philmd@redhat.com \
--cc=amit@kernel.org \
--cc=anthony.perard@citrix.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@gibson.dropbear.id.au \
--cc=jasowang@redhat.com \
--cc=kraxel@redhat.com \
--cc=lizhijian@cn.fujitsu.com \
--cc=marcandre.lureau@redhat.com \
--cc=minyard@acm.org \
--cc=mst@redhat.com \
--cc=pasic@linux.ibm.com \
--cc=paul.durrant@citrix.com \
--cc=pavel.dovgaluk@ispras.ru \
--cc=pbonzini@redhat.com \
--cc=pjp@fedoraproject.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=sstabellini@kernel.org \
--cc=stefanb@linux.ibm.com \
--cc=xen-devel@lists.xenproject.org \
--cc=zhangckid@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).