[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[qemu-s390x] [PATCH v3 02/25] chardev: Assert IOCanReadHandler can not b
From: |
Philippe Mathieu-Daudé |
Subject: |
[qemu-s390x] [PATCH v3 02/25] chardev: Assert IOCanReadHandler can not be negative |
Date: |
Wed, 20 Feb 2019 02:02:09 +0100 |
The backend should not return a negative length to read.
We will later change the prototype of IOCanReadHandler to return an
unsigned length. Meanwhile make sure the return length is positive.
Suggested-by: Paolo Bonzini <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
---
chardev/char.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/chardev/char.c b/chardev/char.c
index f6d61fa5f8..71ecd32b25 100644
--- a/chardev/char.c
+++ b/chardev/char.c
@@ -159,12 +159,15 @@ int qemu_chr_write(Chardev *s, const uint8_t *buf, int
len, bool write_all)
int qemu_chr_be_can_write(Chardev *s)
{
CharBackend *be = s->be;
+ int receivable_bytes;
if (!be || !be->chr_can_read) {
return 0;
}
- return be->chr_can_read(be->opaque);
+ receivable_bytes = be->chr_can_read(be->opaque);
+ assert(receivable_bytes >= 0);
+ return receivable_bytes;
}
void qemu_chr_be_write_impl(Chardev *s, uint8_t *buf, int len)
--
2.20.1
[qemu-s390x] [PATCH v3 19/25] s390/ebcdic: Use size_t to iterate over arrays, Philippe Mathieu-Daudé, 2019/02/19