Patchwork [04/11] acpi_table_add(): introduce 'qemu_len' variable

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

Comments

Eduardo Habkost - June 27, 2012, 8:23 p.m.
To make the length calculation clearer, introduce a 'qemu_len' variable,
for the length of all data being added to acpi_tables (including the
QEMU-specific prefix).

No behavior change, just make the length calculation clearer.

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

Patch

diff --git a/hw/acpi.c b/hw/acpi.c
index abc959e..b5f0531 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -86,7 +86,8 @@  int acpi_table_add(const char *t)
 {
     char buf[1024], *p, *f;
     unsigned long val;
-    size_t acpi_len, start, allen;
+    size_t start, allen;
+    size_t qemu_len, acpi_len;
     bool has_header;
     int changed;
     int r;
@@ -150,13 +151,17 @@  int acpi_table_add(const char *t)
     /* now fill in the header fields */
 
     f = acpi_tables + start;   /* start of the table */
+
+    /* length of the whole table, including our prefix */
+    qemu_len = allen - start;
+
     changed = 0;
 
     /* copy the header to temp place to align the fields */
     memcpy(&hdr, has_header ? f : dfl_hdr, ACPI_TABLE_HDR_SIZE);
 
     /* length of the table minus our prefix */
-    acpi_len = allen - start - ACPI_TABLE_PFX_SIZE;
+    acpi_len = qemu_len - ACPI_TABLE_PFX_SIZE;
 
     hdr._length = cpu_to_le16(acpi_len);