Patchwork [02/11] acpi_table_add(): extract acpi_tables init to separate function

login
register
mail settings
Submitter Eduardo Habkost
Date June 27, 2012, 8:22 p.m.
Message ID <1340828587-15201-3-git-send-email-ehabkost@redhat.com>
Download mbox | patch
Permalink /patch/167746/
State New
Headers show

Comments

Eduardo Habkost - June 27, 2012, 8:22 p.m.
No behavior change, just code movement.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/acpi.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index 21e573b..6180c7a 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -72,6 +72,15 @@  static void strzcpy(char *dst, const char *src, size_t size)
     memcpy(dst, src, len);
 }
 
+/* Init acpi_tables if necessary */
+static void init_acpi_tables(void)
+{
+    if (!acpi_tables) {
+        acpi_tables_len = sizeof(uint16_t);
+        acpi_tables = g_malloc0(acpi_tables_len);
+    }
+}
+
 /* XXX fixme: this function uses obsolete argument parsing interface */
 int acpi_table_add(const char *t)
 {
@@ -101,10 +110,7 @@  int acpi_table_add(const char *t)
         return -1;
     }
 
-    if (!acpi_tables) {
-        acpi_tables_len = sizeof(uint16_t);
-        acpi_tables = g_malloc0(acpi_tables_len);
-    }
+    init_acpi_tables();
 
     allen = acpi_tables_len;
     start = allen;