b28c64
From a14715c6b64f4764259028923a9c04ae7844c546 Mon Sep 17 00:00:00 2001
b28c64
From: Fam Zheng <famz@redhat.com>
b28c64
Date: Fri, 19 May 2017 00:35:11 +0200
b28c64
Subject: [PATCH 06/18] char/serial: Fix emptyness handling
b28c64
b28c64
RH-Author: Fam Zheng <famz@redhat.com>
b28c64
Message-id: <20170519003523.21163-7-famz@redhat.com>
b28c64
Patchwork-id: 75359
b28c64
O-Subject: [RHEL-7.3.z qemu-kvm PATCH 06/18] char/serial: Fix emptyness handling
b28c64
Bugzilla: 1452332
b28c64
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
b28c64
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
b28c64
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
b28c64
b28c64
From: Don Slutz <dslutz@verizon.com>
b28c64
b28c64
The commit 88c1ee73d3231c74ff90bcfc084a7589670ec244
b28c64
char/serial: Fix emptyness check
b28c64
b28c64
Still causes extra NULL byte(s) to be sent.
b28c64
b28c64
So if the fifo is empty, do not send an extra NULL byte.
b28c64
b28c64
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
b28c64
Signed-off-by: Don Slutz <dslutz@verizon.com>
b28c64
Message-id: 1395160174-16006-1-git-send-email-dslutz@verizon.com
b28c64
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
b28c64
(cherry picked from commit dffacd4654ec8bf2898aed230852154c6ed755ed)
b28c64
Signed-off-by: Fam Zheng <famz@redhat.com>
b28c64
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
b28c64
---
b28c64
 hw/char/serial.c | 6 ++++--
b28c64
 1 file changed, 4 insertions(+), 2 deletions(-)
b28c64
b28c64
diff --git a/hw/char/serial.c b/hw/char/serial.c
b28c64
index 489a885..e020b0e 100644
b28c64
--- a/hw/char/serial.c
b28c64
+++ b/hw/char/serial.c
b28c64
@@ -225,8 +225,10 @@ static gboolean serial_xmit(GIOChannel *chan, GIOCondition cond, void *opaque)
b28c64
 
b28c64
     if (s->tsr_retry <= 0) {
b28c64
         if (s->fcr & UART_FCR_FE) {
b28c64
-            s->tsr = fifo8_is_empty(&s->xmit_fifo) ?
b28c64
-                        0 : fifo8_pop(&s->xmit_fifo);
b28c64
+            if (fifo8_is_empty(&s->xmit_fifo)) {
b28c64
+                return FALSE;
b28c64
+            }
b28c64
+            s->tsr = fifo8_pop(&s->xmit_fifo);
b28c64
             if (!s->xmit_fifo.num) {
b28c64
                 s->lsr |= UART_LSR_THRE;
b28c64
             }
b28c64
-- 
b28c64
1.8.3.1
b28c64