Patchwork [2/4] char: fix return value of can_read functions on no input

login
register
mail settings
Submitter Amit Shah
Date Feb. 4, 2013, 12:50 p.m.
Message ID <a0da09309a06753f17a533ca795a105aa2d2fa1f.1359982059.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/218042/
State New
Headers show

Comments

Amit Shah - Feb. 4, 2013, 12:50 p.m.
When the can_read functions report the frontend isn't ready to accept
data yet, return 'FALSE' instead of 'TRUE'.

Signed-off-by: Amit Shah <amit.shah@redhat.com>
---
 qemu-char.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/qemu-char.c b/qemu-char.c
index 5731d02..7fa9372 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -1067,7 +1067,7 @@  static gboolean pty_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
     if (len > s->read_bytes)
         len = s->read_bytes;
     if (len == 0)
-        return TRUE;
+        return FALSE;
     status = g_io_channel_read_chars(s->fd, (gchar *)buf, len, &size, NULL);
     if (status != G_IO_STATUS_NORMAL) {
         pty_chr_state(chr, 0);
@@ -2237,7 +2237,7 @@  static gboolean udp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
     GIOStatus status;
 
     if (s->max_size == 0)
-        return TRUE;
+        return FALSE;
     status = g_io_channel_read_chars(s->chan, (gchar *)s->buf, sizeof(s->buf),
                                      &bytes_read, NULL);
     s->bufcnt = bytes_read;
@@ -2492,7 +2492,7 @@  static gboolean tcp_chr_read(GIOChannel *chan, GIOCondition cond, void *opaque)
     int len, size;
 
     if (!s->connected || s->max_size <= 0) {
-        return TRUE;
+        return FALSE;
     }
     len = sizeof(buf);
     if (len > s->max_size)