* grub-core/loader/i386/bsd.c (grub_netbsd_add_boot_disk_and_wedge):

Use union to avoid breaking strict-aliasing rules.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-10-25 18:20:39 +02:00
parent e12119495d
commit db82136381
2 changed files with 16 additions and 9 deletions
ChangeLog
grub-core/loader/i386

View file

@ -1,3 +1,8 @@
2011-10-25 Vladimir Serbinenko <phcoder@gmail.com>
* grub-core/loader/i386/bsd.c (grub_netbsd_add_boot_disk_and_wedge):
Use union to avoid breaking strict-aliasing rules.
2011-10-25 Vladimir Serbinenko <phcoder@gmail.com>
Support multi-extent iso files.

View file

@ -960,8 +960,10 @@ grub_netbsd_add_boot_disk_and_wedge (void)
grub_partition_t part;
grub_uint32_t biosdev;
grub_uint32_t partmapsector;
struct grub_partition_bsd_disk_label *label;
grub_uint64_t buf[GRUB_DISK_SECTOR_SIZE / 8];
union {
grub_uint64_t raw[GRUB_DISK_SECTOR_SIZE / 8];
struct grub_partition_bsd_disk_label label;
} buf;
grub_uint8_t *hash;
grub_uint64_t ctx[(GRUB_MD_MD5->contextsize + 7) / 8];
@ -981,7 +983,8 @@ grub_netbsd_add_boot_disk_and_wedge (void)
partmapsector = grub_partition_get_start (part->parent) + part->offset;
disk->partition = part->parent;
if (grub_disk_read (disk, part->offset, 0, GRUB_DISK_SECTOR_SIZE, buf) != GRUB_ERR_NONE)
if (grub_disk_read (disk, part->offset, 0, GRUB_DISK_SECTOR_SIZE, buf.raw)
!= GRUB_ERR_NONE)
goto fail;
disk->partition = part;
@ -997,7 +1000,7 @@ grub_netbsd_add_boot_disk_and_wedge (void)
biw.matchnblks = 1;
GRUB_MD_MD5->init (&ctx);
GRUB_MD_MD5->write (&ctx, buf, GRUB_DISK_SECTOR_SIZE);
GRUB_MD_MD5->write (&ctx, buf.raw, GRUB_DISK_SECTOR_SIZE);
GRUB_MD_MD5->final (&ctx);
hash = GRUB_MD_MD5->read (&ctx);
memcpy (biw.matchhash, hash, 16);
@ -1006,18 +1009,17 @@ grub_netbsd_add_boot_disk_and_wedge (void)
}
/* Fill bootdisk if this a NetBSD disk label. */
label = (struct grub_partition_bsd_disk_label *) &buf;
if (part->partmap != NULL &&
(grub_strcmp (part->partmap->name, "netbsd") == 0) &&
label->magic == grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
buf.label.magic == grub_cpu_to_le32 (GRUB_PC_PARTITION_BSD_LABEL_MAGIC))
{
struct grub_netbsd_btinfo_bootdisk bid;
grub_memset (&bid, 0, sizeof (bid));
bid.labelsector = partmapsector;
bid.label.type = label->type;
bid.label.checksum = label->checksum;
memcpy (bid.label.packname, label->packname, 16);
bid.label.type = buf.label.type;
bid.label.checksum = buf.label.checksum;
memcpy (bid.label.packname, buf.label.packname, 16);
bid.biosdev = biosdev;
bid.partition = part->number;
grub_bsd_add_meta (NETBSD_BTINFO_BOOTDISK, &bid, sizeof (bid));