* grub-core/commands/acpi.c: Use sizeof rather than hardcoding the size.

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2013-04-05 11:01:19 +02:00
parent 1865baa72c
commit de73de1748
2 changed files with 10 additions and 6 deletions

View file

@ -1,3 +1,7 @@
2013-04-05 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/commands/acpi.c: Use sizeof rather than hardcoding the size.
2013-04-05 Vladimir Serbinenko <phcoder@gmail.com> 2013-04-05 Vladimir Serbinenko <phcoder@gmail.com>
Replace 8 with GRUB_CHAR_BIT in several places when appropriate. Replace 8 with GRUB_CHAR_BIT in several places when appropriate.

View file

@ -365,13 +365,13 @@ setup_common_tables (void)
numoftables++; numoftables++;
rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr; rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr;
playground_ptr += sizeof (struct grub_acpi_table_header) + 4 * numoftables; playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
rsdt_entry = (grub_uint32_t *) (rsdt + 1); rsdt_entry = (grub_uint32_t *) (rsdt + 1);
/* Fill RSDT header. */ /* Fill RSDT header. */
grub_memcpy (&(rsdt->signature), "RSDT", 4); grub_memcpy (&(rsdt->signature), "RSDT", 4);
rsdt->length = sizeof (struct grub_acpi_table_header) + 4 * numoftables; rsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
rsdt->revision = 1; rsdt->revision = 1;
grub_memcpy (&(rsdt->oemid), root_oemid, sizeof (rsdt->oemid)); grub_memcpy (&(rsdt->oemid), root_oemid, sizeof (rsdt->oemid));
grub_memcpy (&(rsdt->oemtable), root_oemtable, sizeof (rsdt->oemtable)); grub_memcpy (&(rsdt->oemtable), root_oemtable, sizeof (rsdt->oemtable));
@ -419,13 +419,13 @@ setv2table (void)
/* Create XSDT. */ /* Create XSDT. */
xsdt = (struct grub_acpi_table_header *) playground_ptr; xsdt = (struct grub_acpi_table_header *) playground_ptr;
playground_ptr += sizeof (struct grub_acpi_table_header) + 8 * numoftables; playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
xsdt_entry = (grub_uint64_t *)(xsdt + 1); xsdt_entry = (grub_uint64_t *)(xsdt + 1);
for (cur = acpi_tables; cur; cur = cur->next) for (cur = acpi_tables; cur; cur = cur->next)
*(xsdt_entry++) = (grub_addr_t) cur->addr; *(xsdt_entry++) = (grub_addr_t) cur->addr;
grub_memcpy (&(xsdt->signature), "XSDT", 4); grub_memcpy (&(xsdt->signature), "XSDT", 4);
xsdt->length = sizeof (struct grub_acpi_table_header) + 8 * numoftables; xsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
xsdt->revision = 1; xsdt->revision = 1;
grub_memcpy (&(xsdt->oemid), root_oemid, sizeof (xsdt->oemid)); grub_memcpy (&(xsdt->oemid), root_oemid, sizeof (xsdt->oemid));
grub_memcpy (&(xsdt->oemtable), root_oemtable, sizeof (xsdt->oemtable)); grub_memcpy (&(xsdt->oemtable), root_oemtable, sizeof (xsdt->oemtable));
@ -708,11 +708,11 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
/* DSDT. */ /* DSDT. */
playground_size += dsdt_size; playground_size += dsdt_size;
/* RSDT. */ /* RSDT. */
playground_size += sizeof (struct grub_acpi_table_header) + 4 * numoftables; playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
/* RSDPv1. */ /* RSDPv1. */
playground_size += sizeof (struct grub_acpi_rsdp_v10); playground_size += sizeof (struct grub_acpi_rsdp_v10);
/* XSDT. */ /* XSDT. */
playground_size += sizeof (struct grub_acpi_table_header) + 8 * numoftables; playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
/* RSDPv2. */ /* RSDPv2. */
playground_size += sizeof (struct grub_acpi_rsdp_v20); playground_size += sizeof (struct grub_acpi_rsdp_v20);