[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v3 16/25] tpm: Use size_t to hold sizes



On Wed, Feb 20, 2019 at 2:06 AM Philippe Mathieu-Daudé
<philmd@xxxxxxxxxx> wrote:
>
> Avoid to use a signed type to hold an unsigned value.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>


Reviewed-by: Marc-André Lureau <marcandre.lureau@xxxxxxxxxx>

> ---
>  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
>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.