diff mbox series

[4/4] xen/console: Simplify domU console handling in guest_console_write

Message ID 20190402164238.1815-5-julien.grall@arm.com (mailing list archive)
State New, archived
Headers show
Series xen/console: Bug fixes and doc improvement | expand

Commit Message

Julien Grall April 2, 2019, 4:42 p.m. UTC
2 paths in the domU console handling are now the same. So they can be
merged to make the code simpler.

Signed-off-by: Julien Grall <julien.grall@arm.com>
---
 xen/drivers/char/console.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

Comments

Wei Liu April 3, 2019, 11:42 a.m. UTC | #1
On Tue, Apr 02, 2019 at 05:42:38PM +0100, Julien Grall wrote:
> 2 paths in the domU console handling are now the same. So they can be
> merged to make the code simpler.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Acked-by: Wei Liu <wei.liu2@citrix.com>

(This obviously is dependent on the acceptance of patch 2)
Stefano Stabellini April 16, 2019, 8:48 p.m. UTC | #2
On Tue, 2 Apr 2019, Julien Grall wrote:
> 2 paths in the domU console handling are now the same. So they can be
> merged to make the code simpler.
> 
> Signed-off-by: Julien Grall <julien.grall@arm.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
>  xen/drivers/char/console.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
> index b119bf980b..5483d66512 100644
> --- a/xen/drivers/char/console.c
> +++ b/xen/drivers/char/console.c
> @@ -584,13 +584,8 @@ static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)
>              *kout = '\0';
>              spin_lock(&cd->pbuf_lock);
>              kcount = kin - kbuf;
> -            if ( c == '\n' )
> -            {
> -                cd->pbuf[cd->pbuf_idx] = '\0';
> -                guest_printk(cd, XENLOG_G_DEBUG "%s%s\n", cd->pbuf, kbuf);
> -                cd->pbuf_idx = 0;
> -            }
> -            else if ( cd->pbuf_idx + (kout - kbuf) < (DOMAIN_PBUF_SIZE - 1) )
> +            if ( c != '\n' &&
> +                (cd->pbuf_idx + (kout - kbuf) < (DOMAIN_PBUF_SIZE - 1)) )
>              {
>                  /* buffer the output until a newline */
>                  memcpy(cd->pbuf + cd->pbuf_idx, kbuf, kout - kbuf);
> -- 
> 2.11.0
>
diff mbox series

Patch

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index b119bf980b..5483d66512 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -584,13 +584,8 @@  static long guest_console_write(XEN_GUEST_HANDLE_PARAM(char) buffer, int count)
             *kout = '\0';
             spin_lock(&cd->pbuf_lock);
             kcount = kin - kbuf;
-            if ( c == '\n' )
-            {
-                cd->pbuf[cd->pbuf_idx] = '\0';
-                guest_printk(cd, XENLOG_G_DEBUG "%s%s\n", cd->pbuf, kbuf);
-                cd->pbuf_idx = 0;
-            }
-            else if ( cd->pbuf_idx + (kout - kbuf) < (DOMAIN_PBUF_SIZE - 1) )
+            if ( c != '\n' &&
+                (cd->pbuf_idx + (kout - kbuf) < (DOMAIN_PBUF_SIZE - 1)) )
             {
                 /* buffer the output until a newline */
                 memcpy(cd->pbuf + cd->pbuf_idx, kbuf, kout - kbuf);