[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes
From: |
Marc-André Lureau |
Subject: |
Re: [qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes |
Date: |
Wed, 20 Feb 2019 12:22:30 +0100 |
On Wed, Feb 20, 2019 at 2:06 AM Philippe Mathieu-Daudé
<address@hidden> wrote:
>
> Avoid to use a signed type to hold an unsigned value.
>
> Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Reviewed-by: Marc-André Lureau <address@hidden>
> ---
> hw/tpm/tpm_emulator.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/hw/tpm/tpm_emulator.c b/hw/tpm/tpm_emulator.c
> index 70f4b10284..931e56f6ed 100644
> --- a/hw/tpm/tpm_emulator.c
> +++ b/hw/tpm/tpm_emulator.c
> @@ -87,17 +87,18 @@ static int tpm_emulator_ctrlcmd(TPMEmulator *tpm,
> unsigned long cmd, void *msg,
> {
> CharBackend *dev = &tpm->ctrl_chr;
> uint32_t cmd_no = cpu_to_be32(cmd);
> - ssize_t n = sizeof(uint32_t) + msg_len_in;
> + size_t sz = sizeof(uint32_t) + msg_len_in;
> + ssize_t n;
> uint8_t *buf = NULL;
> int ret = -1;
>
> qemu_mutex_lock(&tpm->mutex);
>
> - buf = g_alloca(n);
> + buf = g_alloca(sz);
> memcpy(buf, &cmd_no, sizeof(cmd_no));
> memcpy(buf + sizeof(cmd_no), msg, msg_len_in);
>
> - n = qemu_chr_fe_write_all(dev, buf, n);
> + n = qemu_chr_fe_write_all(dev, buf, sz);
> if (n <= 0) {
> goto end;
> }
> --
> 2.20.1
>
- [qemu-s390x] [PATCH v3 23/25] hw/ipmi: Assert outlen > outpos, (continued)
- [qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes, Philippe Mathieu-Daudé, 2019/02/19
- Re: [qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes,
Marc-André Lureau <=
- [qemu-s390x] [PATCH v3 18/25] s390x/3270: Let insert_IAC_escape_char() use size_t, Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 21/25] s390x/sclp: Use size_t in process_mdb(), Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 22/25] s390x/sclp: Let write_console_data() take a size_t, Philippe Mathieu-Daudé, 2019/02/19
- [qemu-s390x] [PATCH v3 24/25] chardev: Let qemu_chr_fe_write[_all] use size_t type argument, Philippe Mathieu-Daudé, 2019/02/19
- Re: [qemu-s390x] [PATCH v3 00/25] chardev: Convert qemu_chr_write() to take a size_t argument, Marc-André Lureau, 2019/02/20