diff mbox

[11/11] acpi_table_add(): extract acpi_tables count update code to separate function

Message ID 1340828587-15201-12-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost June 27, 2012, 8:23 p.m. UTC
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 <ehabkost@redhat.com>
---
 hw/acpi.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
diff mbox

Patch

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;
 
 }