acpi: build_waet: use acpi_table_begin()/acpi_table_end() instead of build_header()

it replaces error-prone pointer arithmetic for build_header() API,
with 2 calls to start and finish table creation,
which hides offsets magic from API user.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Message-Id: <20210924122802.1455362-20-imammedo@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
Igor Mammedov 2021-09-24 08:27:46 -04:00 committed by Michael S. Tsirkin
parent 91a6b97569
commit eaa507646d

View File

@ -2223,10 +2223,10 @@ static void
build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id, build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
const char *oem_table_id) const char *oem_table_id)
{ {
int waet_start = table_data->len; AcpiTable table = { .sig = "WAET", .rev = 1, .oem_id = oem_id,
.oem_table_id = oem_table_id };
/* WAET header */ acpi_table_begin(&table, table_data);
acpi_data_push(table_data, sizeof(AcpiTableHeader));
/* /*
* Set "ACPI PM timer good" flag. * Set "ACPI PM timer good" flag.
* *
@ -2235,9 +2235,7 @@ build_waet(GArray *table_data, BIOSLinker *linker, const char *oem_id,
* Which avoids costly VMExits caused by guest re-reading it unnecessarily. * Which avoids costly VMExits caused by guest re-reading it unnecessarily.
*/ */
build_append_int_noprefix(table_data, 1 << 1 /* ACPI PM timer good */, 4); build_append_int_noprefix(table_data, 1 << 1 /* ACPI PM timer good */, 4);
acpi_table_end(linker, &table);
build_header(linker, table_data, (void *)(table_data->data + waet_start),
"WAET", table_data->len - waet_start, 1, oem_id, oem_table_id);
} }
/* /*