[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v3 01/25] chardev: Simplify IOWatchPoll::fd_can_read as a GSourceFunc
On Wed, Feb 20, 2019 at 2:03 AM Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> wrote: > > 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@xxxxxxxxxx> > Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx> > --- > 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 > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |