From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([209.51.188.92]:41858) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gwGRr-00076E-0Q for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:13:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gwGRb-0005IO-3p for qemu-devel@nongnu.org; Tue, 19 Feb 2019 20:13:10 -0500 From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Wed, 20 Feb 2019 02:02:23 +0100 Message-Id: <20190220010232.18731-17-philmd@redhat.com> In-Reply-To: <20190220010232.18731-1-philmd@redhat.com> References: <20190220010232.18731-1-philmd@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH v3 16/25] tpm: Use size_t to hold sizes List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, Prasad J Pandit , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini Cc: Jason Wang , Anthony Perard , qemu-ppc@nongnu.org, Stefan Berger , David Gibson , Gerd Hoffmann , Zhang Chen , xen-devel@lists.xenproject.org, Cornelia Huck , Samuel Thibault , Christian Borntraeger , Amit Shah , Li Zhijian , Corey Minyard , "Michael S. Tsirkin" , Paul Durrant , Halil Pasic , Stefano Stabellini , qemu-s390x@nongnu.org, Pavel Dovgalyuk , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Avoid to use a signed type to hold an unsigned value. Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- 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, uns= igned long cmd, void *msg, { CharBackend *dev =3D &tpm->ctrl_chr; uint32_t cmd_no =3D cpu_to_be32(cmd); - ssize_t n =3D sizeof(uint32_t) + msg_len_in; + size_t sz =3D sizeof(uint32_t) + msg_len_in; + ssize_t n; uint8_t *buf =3D NULL; int ret =3D -1; =20 qemu_mutex_lock(&tpm->mutex); =20 - buf =3D g_alloca(n); + buf =3D g_alloca(sz); memcpy(buf, &cmd_no, sizeof(cmd_no)); memcpy(buf + sizeof(cmd_no), msg, msg_len_in); =20 - n =3D qemu_chr_fe_write_all(dev, buf, n); + n =3D qemu_chr_fe_write_all(dev, buf, sz); if (n <=3D 0) { goto end; } --=20 2.20.1