This is the last change needed to eliminate all the acpi_tables/acpi_tables_len math from acpi_table_add(), making that function only take care of the under-construction table (the newtable/newlen variables).
No behavior change, just code movement. Signed-off-by: Eduardo Habkost <ehabk...@redhat.com> --- hw/acpi.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 240e2cf..9611145 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -93,6 +93,18 @@ static char *acpi_newtable_resize(size_t newlen) return acpi_tables + acpi_tables_len; } +/* Increase the acpi_tables table count, and adjust acpi_tables_len + */ +static void acpi_newtable_finished(size_t len) +{ + /* increase number of tables */ + (*(uint16_t *)acpi_tables) = + cpu_to_le32(le32_to_cpu(*(uint16_t *)acpi_tables) + 1); + + acpi_tables_len += len; +} + + static int acpi_make_table_header(const char *t, bool has_header, char *f, size_t qemu_len) { @@ -264,11 +276,7 @@ int acpi_table_add(const char *t) return -1; } - /* increase number of tables */ - (*(uint16_t *)acpi_tables) = - cpu_to_le32(le32_to_cpu(*(uint16_t *)acpi_tables) + 1); - - acpi_tables_len += newlen; + acpi_newtable_finished(newlen); return 0; } -- 1.7.10.4