Commit c535149240 for qemu.org
commit c535149240e85ed974b7717b61c9f6b2f42283aa
Author: Marc-André Lureau <marcandre.lureau@redhat.com>
Date: Sun Oct 4 14:23:36 2026 +0400
chardev/char-udp: clarify read_poll return value with pending data
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 <marcandre.lureau@redhat.com>
Message-ID: <20261004-issue-4560-v1-22-ccbef537cbeb@redhat.com>
diff --git a/chardev/char-udp.c b/chardev/char-udp.c
index 423000832f..618fd8f135 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;
}