From nobody Mon Feb 9 19:30:13 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1504267026339543.1064890721161; Fri, 1 Sep 2017 04:57:06 -0700 (PDT) Received: from localhost ([::1]:37343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkZN-0006k5-8J for importer@patchew.org; Fri, 01 Sep 2017 07:57:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dnkXs-0005mH-Sn for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:55:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dnkXo-0007wN-8e for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:55:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57510) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dnkXo-0007wC-2p for qemu-devel@nongnu.org; Fri, 01 Sep 2017 07:55:28 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18D101F570 for ; Fri, 1 Sep 2017 11:55:27 +0000 (UTC) Received: from secure.mitica (ovpn-117-188.ams2.redhat.com [10.36.117.188]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1546E7BB51; Fri, 1 Sep 2017 11:55:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 18D101F570 Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=quintela@redhat.com From: Juan Quintela To: qemu-devel@nongnu.org Date: Fri, 1 Sep 2017 13:55:00 +0200 Message-Id: <20170901115500.12654-3-quintela@redhat.com> In-Reply-To: <20170901115500.12654-1-quintela@redhat.com> References: <20170901115500.12654-1-quintela@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 01 Sep 2017 11:55:27 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v4 2/2] tests: Make vmgenid test compile X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, dgilbert@redhat.com, peterx@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Just make sure that nr_tables is size_t not int. Once there, do the assert in the right place and be sure that we don't have a division by zero. Suggested-by: C=C3=A9dric Le Goater Signed-off-by: Juan Quintela Tested-by: Cleber Rosa -- Drop the s/g_new0/g_malloc0/ change. Avoid division by zero with assert (danp) Reviewed-by: Daniel P. Berrange --- tests/vmgenid-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/vmgenid-test.c b/tests/vmgenid-test.c index 3d5c1c3615..918c82c82a 100644 --- a/tests/vmgenid-test.c +++ b/tests/vmgenid-test.c @@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(void) AcpiRsdpDescriptor rsdp_table; uint32_t rsdt; AcpiRsdtDescriptorRev1 rsdt_table; - int tables_nr; + size_t tables_nr; uint32_t *tables; AcpiTableHeader ssdt_table; VgidTable vgid_table; @@ -62,9 +62,9 @@ static uint32_t acpi_find_vgia(void) ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT"); =20 /* compute the table entries in rsdt */ + g_assert_cmpint(rsdt_table.length, >, sizeof(AcpiRsdtDescriptorRev1)); tables_nr =3D (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) / sizeof(uint32_t); - g_assert_cmpint(tables_nr, >, 0); =20 /* get the addresses of the tables pointed by rsdt */ tables =3D g_new0(uint32_t, tables_nr); --=20 2.13.5