diff mbox series

[v3,21/25] s390x/sclp: Use size_t in process_mdb()

Message ID 20190220010232.18731-22-philmd@redhat.com
State New
Headers show
Series chardev: Convert qemu_chr_write() to take a size_t argument | expand

Commit Message

Philippe Mathieu-Daudé Feb. 20, 2019, 1:02 a.m. UTC
Since it is unlikely we have sizeof(mdbo->mto.message) < 0,
we can convert this variable to an unsigned type.

Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 hw/char/sclpconsole-lm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Cornelia Huck Feb. 20, 2019, 10:53 a.m. UTC | #1
On Wed, 20 Feb 2019 02:02:28 +0100
Philippe Mathieu-Daudé <philmd@redhat.com> wrote:

> Since it is unlikely we have sizeof(mdbo->mto.message) < 0,
> we can convert this variable to an unsigned type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  hw/char/sclpconsole-lm.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>
diff mbox series

Patch

diff --git a/hw/char/sclpconsole-lm.c b/hw/char/sclpconsole-lm.c
index 49543e2c83..48c76d863e 100644
--- a/hw/char/sclpconsole-lm.c
+++ b/hw/char/sclpconsole-lm.c
@@ -208,7 +208,7 @@  static int write_console_data(SCLPEvent *event, const uint8_t *buf, int len)
 static int process_mdb(SCLPEvent *event, MDBO *mdbo)
 {
     int rc;
-    int len;
+    uint16_t len;
     uint8_t buffer[SIZE_BUFFER];
     const size_t hlen = sizeof(mdbo->length)
             + sizeof(mdbo->type)
@@ -217,6 +217,7 @@  static int process_mdb(SCLPEvent *event, MDBO *mdbo)
             + sizeof(mdbo->mto._reserved);
 
     len = be16_to_cpu(mdbo->length);
+    assert(len >= hlen);
     len -= hlen;
     assert(len <= SIZE_BUFFER);