Message ID | 20190220010232.18731-12-philmd@redhat.com |
---|---|
State | New |
Headers | show |
Series | chardev: Convert qemu_chr_write() to take a size_t argument | expand |
On Wed, Feb 20, 2019 at 2:05 AM Philippe Mathieu-Daudé <philmd@redhat.com> wrote: > > The single caller of xencons_send(), con_event() already use the > difference 'con->buffer.size - con->buffer.consumed'. > Deduplicate by passing the difference as an argument. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> > --- > hw/char/xen_console.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c > index 91f34ef06c..083b2c8e2a 100644 > --- a/hw/char/xen_console.c > +++ b/hw/char/xen_console.c > @@ -144,11 +144,10 @@ static void xencons_receive(void *opaque, const uint8_t *buf, int len) > xen_pv_send_notify(&con->xendev); > } > > -static void xencons_send(struct XenConsole *con) > +static void xencons_send(struct XenConsole *con, ssize_t size) > { > - ssize_t len, size; > + ssize_t len; > > - size = con->buffer.size - con->buffer.consumed; > if (qemu_chr_fe_backend_connected(&con->chr)) { > len = qemu_chr_fe_write(&con->chr, > con->buffer.data + con->buffer.consumed, > @@ -280,10 +279,13 @@ static void con_disconnect(struct XenLegacyDevice *xendev) > static void con_event(struct XenLegacyDevice *xendev) > { > struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); > + ssize_t size; > > buffer_append(con); > - if (con->buffer.size - con->buffer.consumed) > - xencons_send(con); > + size = con->buffer.size - con->buffer.consumed; > + if (size) { > + xencons_send(con, size); > + } > } > > /* -------------------------------------------------------------------- */ > -- > 2.20.1 >
> -----Original Message----- > From: Philippe Mathieu-Daudé [mailto:philmd@redhat.com] > Sent: 20 February 2019 01:02 > 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: [PATCH v3 11/25] xen: Let xencons_send() take a 'size' argument > > The single caller of xencons_send(), con_event() already use the > difference 'con->buffer.size - con->buffer.consumed'. > Deduplicate by passing the difference as an argument. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> > --- > hw/char/xen_console.c | 12 +++++++----- > 1 file changed, 7 insertions(+), 5 deletions(-) > > diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c > index 91f34ef06c..083b2c8e2a 100644 > --- a/hw/char/xen_console.c > +++ b/hw/char/xen_console.c > @@ -144,11 +144,10 @@ static void xencons_receive(void *opaque, const > uint8_t *buf, int len) > xen_pv_send_notify(&con->xendev); > } > > -static void xencons_send(struct XenConsole *con) > +static void xencons_send(struct XenConsole *con, ssize_t size) > { > - ssize_t len, size; > + ssize_t len; > > - size = con->buffer.size - con->buffer.consumed; > if (qemu_chr_fe_backend_connected(&con->chr)) { > len = qemu_chr_fe_write(&con->chr, > con->buffer.data + con->buffer.consumed, > @@ -280,10 +279,13 @@ static void con_disconnect(struct XenLegacyDevice > *xendev) > static void con_event(struct XenLegacyDevice *xendev) > { > struct XenConsole *con = container_of(xendev, struct XenConsole, > xendev); > + ssize_t size; > > buffer_append(con); > - if (con->buffer.size - con->buffer.consumed) > - xencons_send(con); > + size = con->buffer.size - con->buffer.consumed; > + if (size) { > + xencons_send(con, size); > + } You introduce this here, only to modify it in patch #12. Why not squash the two together? Paul > } > > /* -------------------------------------------------------------------- > */ > -- > 2.20.1
diff --git a/hw/char/xen_console.c b/hw/char/xen_console.c index 91f34ef06c..083b2c8e2a 100644 --- a/hw/char/xen_console.c +++ b/hw/char/xen_console.c @@ -144,11 +144,10 @@ static void xencons_receive(void *opaque, const uint8_t *buf, int len) xen_pv_send_notify(&con->xendev); } -static void xencons_send(struct XenConsole *con) +static void xencons_send(struct XenConsole *con, ssize_t size) { - ssize_t len, size; + ssize_t len; - size = con->buffer.size - con->buffer.consumed; if (qemu_chr_fe_backend_connected(&con->chr)) { len = qemu_chr_fe_write(&con->chr, con->buffer.data + con->buffer.consumed, @@ -280,10 +279,13 @@ static void con_disconnect(struct XenLegacyDevice *xendev) static void con_event(struct XenLegacyDevice *xendev) { struct XenConsole *con = container_of(xendev, struct XenConsole, xendev); + ssize_t size; buffer_append(con); - if (con->buffer.size - con->buffer.consumed) - xencons_send(con); + size = con->buffer.size - con->buffer.consumed; + if (size) { + xencons_send(con, size); + } } /* -------------------------------------------------------------------- */
The single caller of xencons_send(), con_event() already use the difference 'con->buffer.size - con->buffer.consumed'. Deduplicate by passing the difference as an argument. Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com> --- hw/char/xen_console.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)