31004e
From a3da4fed0728b2ed108fd7b02047e5ea568e8d89 Mon Sep 17 00:00:00 2001
31004e
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
31004e
Date: Fri, 5 Apr 2013 11:01:19 +0200
f74b50
Subject: [PATCH 264/482] 	* grub-core/commands/acpi.c: Use sizeof rather
31004e
 than hardcoding the size.
31004e
31004e
---
31004e
 ChangeLog                 |  4 ++++
31004e
 grub-core/commands/acpi.c | 12 ++++++------
31004e
 2 files changed, 10 insertions(+), 6 deletions(-)
31004e
31004e
diff --git a/ChangeLog b/ChangeLog
31004e
index 7e2a62f..f90fab4 100644
31004e
--- a/ChangeLog
31004e
+++ b/ChangeLog
31004e
@@ -1,5 +1,9 @@
31004e
 2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
31004e
 
31004e
+	* grub-core/commands/acpi.c: Use sizeof rather than hardcoding the size.
31004e
+
31004e
+2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
31004e
+
31004e
 	Replace 8 with GRUB_CHAR_BIT in several places when appropriate.
31004e
 
31004e
 2013-04-05  Vladimir Serbinenko  <phcoder@gmail.com>
31004e
diff --git a/grub-core/commands/acpi.c b/grub-core/commands/acpi.c
31004e
index 4ca8cf7..14f639c 100644
31004e
--- a/grub-core/commands/acpi.c
31004e
+++ b/grub-core/commands/acpi.c
31004e
@@ -365,13 +365,13 @@ setup_common_tables (void)
31004e
     numoftables++;
31004e
 
31004e
   rsdt_addr = rsdt = (struct grub_acpi_table_header *) playground_ptr;
31004e
-  playground_ptr += sizeof (struct grub_acpi_table_header) + 4 * numoftables;
31004e
+  playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
31004e
 
31004e
   rsdt_entry = (grub_uint32_t *) (rsdt + 1);
31004e
 
31004e
   /* Fill RSDT header. */
31004e
   grub_memcpy (&(rsdt->signature), "RSDT", 4);
31004e
-  rsdt->length = sizeof (struct grub_acpi_table_header) + 4 * numoftables;
31004e
+  rsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
31004e
   rsdt->revision = 1;
31004e
   grub_memcpy (&(rsdt->oemid), root_oemid, sizeof (rsdt->oemid));
31004e
   grub_memcpy (&(rsdt->oemtable), root_oemtable, sizeof (rsdt->oemtable));
31004e
@@ -419,13 +419,13 @@ setv2table (void)
31004e
 
31004e
   /* Create XSDT. */
31004e
   xsdt = (struct grub_acpi_table_header *) playground_ptr;
31004e
-  playground_ptr += sizeof (struct grub_acpi_table_header) + 8 * numoftables;
31004e
+  playground_ptr += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
31004e
 
31004e
   xsdt_entry = (grub_uint64_t *)(xsdt + 1);
31004e
   for (cur = acpi_tables; cur; cur = cur->next)
31004e
     *(xsdt_entry++) = (grub_addr_t) cur->addr;
31004e
   grub_memcpy (&(xsdt->signature), "XSDT", 4);
31004e
-  xsdt->length = sizeof (struct grub_acpi_table_header) + 8 * numoftables;
31004e
+  xsdt->length = sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
31004e
   xsdt->revision = 1;
31004e
   grub_memcpy (&(xsdt->oemid), root_oemid, sizeof (xsdt->oemid));
31004e
   grub_memcpy (&(xsdt->oemtable), root_oemtable, sizeof (xsdt->oemtable));
31004e
@@ -708,11 +708,11 @@ grub_cmd_acpi (struct grub_extcmd_context *ctxt, int argc, char **args)
31004e
   /* DSDT. */
31004e
   playground_size += dsdt_size;
31004e
   /* RSDT. */
31004e
-  playground_size += sizeof (struct grub_acpi_table_header) + 4 * numoftables;
31004e
+  playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint32_t) * numoftables;
31004e
   /* RSDPv1. */
31004e
   playground_size += sizeof (struct grub_acpi_rsdp_v10);
31004e
   /* XSDT. */
31004e
-  playground_size += sizeof (struct grub_acpi_table_header) + 8 * numoftables;
31004e
+  playground_size += sizeof (struct grub_acpi_table_header) + sizeof (grub_uint64_t) * numoftables;
31004e
   /* RSDPv2. */
31004e
   playground_size += sizeof (struct grub_acpi_rsdp_v20);
31004e
 
31004e
-- 
31004e
1.8.2.1
31004e