@@ -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);
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(-)