Message ID | 20190220010232.18731-22-philmd@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | chardev: Convert qemu_chr_write() to take a size_t argument | expand |
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 --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);
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(-)