Add a comment explaining why returning s->max_size is safe when
there is unflushed data in the buffer: udp_chr_flush_buffer()
loops while max_size > 0, so max_size is guaranteed to be 0 when
pending data remains.

Signed-off-by: Marc-André Lureau <[email protected]>
---
 chardev/char-udp.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/chardev/char-udp.c b/chardev/char-udp.c
index 423000832ffb..618fd8f135a0 100644
--- a/chardev/char-udp.c
+++ b/chardev/char-udp.c
@@ -81,6 +81,10 @@ static int udp_chr_read_poll(void *opaque)
      */
     udp_chr_flush_buffer(s);
 
+    /*
+     * udp_chr_flush_buffer() loops while max_size > 0 && bufptr < bufcnt,
+     * so when pending data remains it must be because max_size hit 0.
+     */
     return s->max_size;
 }
 

-- 
2.56.0.rc0.29.g47ce80527c56


Reply via email to