From 2dc33c03b0e2f80a10edbdafa4452416d4b61af8 Mon Sep 17 00:00:00 2001 From: robertmh Date: Sat, 23 Feb 2008 20:33:32 +0000 Subject: [PATCH] 2008-02-23 Robert Millan * partmap/gpt.c (grub_gpt_magic): Add `0x' qualifier to each member, since they were intended to be in hex. This didn't break previously because of a bug in gpt_partition_map_iterate() (see below). (gpt_partition_map_iterate): Replace `grub_memcmp' with `! grub_memcmp' when checking the validity of GPT header. Remove `partno', since it always provides the same information as `i'. --- ChangeLog | 10 ++++++++++ partmap/gpt.c | 10 ++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 333383f37..3f8c3b4c1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-02-23 Robert Millan + + * partmap/gpt.c (grub_gpt_magic): Add `0x' qualifier to each member, + since they were intended to be in hex. This didn't break previously + because of a bug in gpt_partition_map_iterate() (see below). + + (gpt_partition_map_iterate): Replace `grub_memcmp' with `! grub_memcmp' + when checking the validity of GPT header. + Remove `partno', since it always provides the same information as `i'. + 2008-02-21 Yoshinori K. Okuji * include/grub/efi/time.h: Fix a wrong comment. diff --git a/partmap/gpt.c b/partmap/gpt.c index 6bc87551d..36eaef21c 100644 --- a/partmap/gpt.c +++ b/partmap/gpt.c @@ -27,7 +27,7 @@ static grub_uint8_t grub_gpt_magic[8] = { - 45, 46, 49, 20, 50, 41, 52, 54 + 0x45, 0x46, 0x49, 0x20, 0x50, 0x41, 0x52, 0x54 }; static const grub_gpt_part_type_t grub_gpt_partition_type_empty = GRUB_GPT_PARTITION_TYPE_EMPTY; @@ -51,7 +51,6 @@ gpt_partition_map_iterate (grub_disk_t disk, struct grub_disk raw; struct grub_pc_partition_mbr mbr; grub_uint64_t entries; - int partno = 0; unsigned int i; int last_offset = 0; @@ -75,7 +74,7 @@ gpt_partition_map_iterate (grub_disk_t disk, if (grub_disk_read (&raw, 1, 0, sizeof (gpt), (char *) &gpt)) return grub_errno; - if (! grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic))) + if (grub_memcmp (gpt.magic, grub_gpt_magic, sizeof (grub_gpt_magic))) return grub_error (GRUB_ERR_BAD_PART_TABLE, "no valid GPT header"); grub_dprintf ("gpt", "Read a valid GPT header\n"); @@ -95,18 +94,17 @@ gpt_partition_map_iterate (grub_disk_t disk, part.len = (grub_le_to_cpu64 (entry.end) - grub_le_to_cpu64 (entry.start) + 1); part.offset = entries; - part.index = partno; + part.index = i; part.partmap = &grub_gpt_partition_map; part.data = &entry; grub_dprintf ("gpt", "GPT entry %d: start=%lld, length=%lld\n", - partno, part.start, part.len); + i, part.start, part.len); if (hook (disk, &part)) return grub_errno; } - partno++; last_offset += grub_le_to_cpu32 (gpt.partentry_size); if (last_offset == GRUB_DISK_SECTOR_SIZE) {