[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 01/11] acpi_table_add(): simplify acpi_tables on-dem
From: |
Eduardo Habkost |
Subject: |
[Qemu-devel] [PATCH 01/11] acpi_table_add(): simplify acpi_tables on-demand initialization |
Date: |
Wed, 27 Jun 2012 17:22:57 -0300 |
Change the code to set acpi_tables_len as soon as acpi_tables is
allocated, so the rest of the code can simply use acpi_tables_len
safely.
There's a small behavior change if the first acpi_table_add() call fails
to open a file, but the change is actually desirable, because the old
code kept 'acpi_tables_len = 0' but a non-NULL 'acpi_tables' on error,
generating an invalid table if a second acpi_add() call were made.
Signed-off-by: Eduardo Habkost <address@hidden>
---
hw/acpi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/acpi.c b/hw/acpi.c
index effc7ec..21e573b 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -102,12 +102,11 @@ int acpi_table_add(const char *t)
}
if (!acpi_tables) {
- allen = sizeof(uint16_t);
- acpi_tables = g_malloc0(allen);
- } else {
- allen = acpi_tables_len;
+ acpi_tables_len = sizeof(uint16_t);
+ acpi_tables = g_malloc0(acpi_tables_len);
}
+ allen = acpi_tables_len;
start = allen;
acpi_tables = g_realloc(acpi_tables, start + ACPI_TABLE_HDR_SIZE);
allen += has_header ? ACPI_TABLE_PFX_SIZE : ACPI_TABLE_HDR_SIZE;
--
1.7.10.4
- [Qemu-devel] [PATCH 00/11] acpi_table_add() code cleanup, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 03/11] acpi_table_add(): rename 'len' to 'acpi_len', Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 04/11] acpi_table_add(): introduce 'qemu_len' variable, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 09/11] acpi_table_add(): extract acpi_tables reallocation code to a separate function, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 05/11] acpi_table_add(): extract ACPI header creation to separate function, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 10/11] acpi_table_add(): use acpi_newtable_resize() return value, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 01/11] acpi_table_add(): simplify acpi_tables on-demand initialization,
Eduardo Habkost <=
- [Qemu-devel] [PATCH 06/11] acpi_table_add(): rename 'qemu_len' to 'newlen', Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 02/11] acpi_table_add(): extract acpi_tables init to separate function, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 07/11] acpi_table_add(): eliminate 'allen' variable, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 08/11] acpi_table_add(): eliminate 'start' variable, Eduardo Habkost, 2012/06/27
- [Qemu-devel] [PATCH 11/11] acpi_table_add(): extract acpi_tables count update code to separate function, Eduardo Habkost, 2012/06/27