gpt: use inline functions for checking status bits

This should prevent bugs like 6078f836 and 4268f3da.
This commit is contained in:
Michael Marineau 2016-09-20 12:43:01 -07:00
parent 4268f3da52
commit 3dda6a863a
4 changed files with 39 additions and 13 deletions

View file

@ -91,7 +91,7 @@ grub_find_next (const char *disk_name,
if (!gpt)
goto done;
if ((gpt->status & GRUB_GPT_BOTH_VALID) != GRUB_GPT_BOTH_VALID)
if (!grub_gpt_both_valid(gpt))
if (grub_gpt_repair (dev->disk, gpt))
goto done;

View file

@ -65,16 +65,16 @@ grub_cmd_gptrepair (grub_command_t cmd __attribute__ ((unused)),
if (!gpt)
goto done;
if ((gpt->status & GRUB_GPT_BOTH_VALID) == GRUB_GPT_BOTH_VALID)
if (grub_gpt_both_valid (gpt))
{
grub_printf_ (N_("GPT already valid, %s unmodified.\n"), dev_name);
goto done;
}
if ((gpt->status & GRUB_GPT_PRIMARY_VALID) != GRUB_GPT_PRIMARY_VALID)
if (!grub_gpt_primary_valid (gpt))
grub_printf_ (N_("Found invalid primary GPT on %s\n"), dev_name);
if ((gpt->status & GRUB_GPT_BACKUP_VALID) != GRUB_GPT_BACKUP_VALID)
if (!grub_gpt_backup_valid (gpt))
grub_printf_ (N_("Found invalid backup GPT on %s\n"), dev_name);
if (grub_gpt_repair (dev->disk, gpt))