qemu-s390x
[Top][All Lists]
Advanced

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

[qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes


From: Philippe Mathieu-Daudé
Subject: [qemu-s390x] [PATCH v3 16/25] tpm: Use size_t to hold sizes
Date: Wed, 20 Feb 2019 02:02:23 +0100

Avoid to use a signed type to hold an unsigned value.

Signed-off-by: Philippe Mathieu-Daudé <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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]