mirror of
https://github.com/xemu-project/xemu.git
synced 2025-01-23 20:36:16 +00:00
tests: Make vmgenid test compile
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édric Le Goater <clg@kaod.org> Signed-off-by: Juan Quintela <quintela@redhat.com> Tested-by: Cleber Rosa <crosa@redhat.com> -- Drop the s/g_new0/g_malloc0/ change. Avoid division by zero with assert (danp)
This commit is contained in:
parent
e3ff9f0e57
commit
c18aaeb690
@ -40,7 +40,7 @@ static uint32_t acpi_find_vgia(void)
|
|||||||
AcpiRsdpDescriptor rsdp_table;
|
AcpiRsdpDescriptor rsdp_table;
|
||||||
uint32_t rsdt;
|
uint32_t rsdt;
|
||||||
AcpiRsdtDescriptorRev1 rsdt_table;
|
AcpiRsdtDescriptorRev1 rsdt_table;
|
||||||
int tables_nr;
|
size_t tables_nr;
|
||||||
uint32_t *tables;
|
uint32_t *tables;
|
||||||
AcpiTableHeader ssdt_table;
|
AcpiTableHeader ssdt_table;
|
||||||
VgidTable vgid_table;
|
VgidTable vgid_table;
|
||||||
@ -62,9 +62,9 @@ static uint32_t acpi_find_vgia(void)
|
|||||||
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
|
ACPI_ASSERT_CMP(rsdt_table.signature, "RSDT");
|
||||||
|
|
||||||
/* compute the table entries in rsdt */
|
/* compute the table entries in rsdt */
|
||||||
|
g_assert_cmpint(rsdt_table.length, >, sizeof(AcpiRsdtDescriptorRev1));
|
||||||
tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
|
tables_nr = (rsdt_table.length - sizeof(AcpiRsdtDescriptorRev1)) /
|
||||||
sizeof(uint32_t);
|
sizeof(uint32_t);
|
||||||
g_assert_cmpint(tables_nr, >, 0);
|
|
||||||
|
|
||||||
/* get the addresses of the tables pointed by rsdt */
|
/* get the addresses of the tables pointed by rsdt */
|
||||||
tables = g_new0(uint32_t, tables_nr);
|
tables = g_new0(uint32_t, tables_nr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user