]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/partmap/sunpc.c (grub_sun_is_valid): Make argument
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 13 Dec 2011 13:42:41 +0000 (14:42 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Tue, 13 Dec 2011 13:42:41 +0000 (14:42 +0100)
uint16_t * to ensure alignment.
(sun_pc_partition_map_iterate): Make `block' a union to ensure
alignment.

ChangeLog
grub-core/partmap/sunpc.c

index d5d98c193bbfb896c11e5996aa324506e9df7b05..c1ac0c00a25c79c4ac94796716b2acfc155e3c87 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,13 @@
 2011-12-13  Vladimir Serbinenko  <phcoder@gmail.com>
 
-       * grub-core/partmap/sun.c (grub_sun_is_valid): make argument uint16_t *
+       * grub-core/partmap/sunpc.c (grub_sun_is_valid): Make argument
+       uint16_t * to ensure alignment.
+       (sun_pc_partition_map_iterate): Make `block' a union to ensure
+       alignment.
+
+2011-12-13  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       * grub-core/partmap/sun.c (grub_sun_is_valid): Make argument uint16_t *
        to ensure alignment.
        (sun_partition_map_iterate): Make `block' a union to ensure alignment.
 
index 28dc4f5be4d41710d266859dee932e07330191eb..1c1fdced05724306d0fc1483e81a90db27cc60e5 100644 (file)
@@ -53,13 +53,13 @@ static struct grub_partition_map grub_sun_pc_partition_map;
 
 /* Verify checksum (true=ok).  */
 static int
-grub_sun_is_valid (struct grub_sun_pc_block *label)
+grub_sun_is_valid (grub_uint16_t *label)
 {
   grub_uint16_t *pos;
   grub_uint16_t sum = 0;
 
-  for (pos = (grub_uint16_t *) label;
-       pos < (grub_uint16_t *) (label + 1);
+  for (pos = label;
+       pos < (label + sizeof (struct grub_sun_pc_block) / 2);
        pos++)
     sum ^= *pos;
 
@@ -72,7 +72,11 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
                                           const grub_partition_t partition))
 {
   grub_partition_t p;
-  struct grub_sun_pc_block block;
+  union
+  {
+    struct grub_sun_pc_block sun;
+    grub_uint16_t raw[0];
+  } block;
   int partnum;
   grub_err_t err;
 
@@ -88,14 +92,14 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
       return err;
     }
   
-  if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.magic))
+  if (GRUB_PARTMAP_SUN_PC_MAGIC != grub_le_to_cpu16 (block.sun.magic))
     {
       grub_free (p);
       return grub_error (GRUB_ERR_BAD_PART_TABLE, 
                         "not a sun_pc partition table");
     }
 
-  if (! grub_sun_is_valid (&block))
+  if (! grub_sun_is_valid (block.raw))
     {
       grub_free (p);
       return grub_error (GRUB_ERR_BAD_PART_TABLE, "invalid checksum");
@@ -107,11 +111,12 @@ sun_pc_partition_map_iterate (grub_disk_t disk,
     {
       struct grub_sun_pc_partition_descriptor *desc;
 
-      if (block.partitions[partnum].id == 0
-         || block.partitions[partnum].id == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
+      if (block.sun.partitions[partnum].id == 0
+         || block.sun.partitions[partnum].id
+         == GRUB_PARTMAP_SUN_PC_WHOLE_DISK_ID)
        continue;
 
-      desc = &block.partitions[partnum];
+      desc = &block.sun.partitions[partnum];
       p->start = grub_le_to_cpu32 (desc->start_sector);
       p->len = grub_le_to_cpu32 (desc->num_sectors);
       p->number = partnum;