]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
commands/file: Fix array/enum desync
authorDerek Foreman <derek@endlessos.org>
Fri, 26 Feb 2021 18:05:07 +0000 (12:05 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 2 Mar 2021 15:46:09 +0000 (16:46 +0100)
The commit f1957dc8a (RISC-V: Add to build system) added two entries to
the options array, but only 1 entry to the enum. This resulted in
everything after the insertion point being off by one.

This broke at least the "file --is-hibernated-hiberfil" command.

Bring the two back in sync by splitting the IS_RISCV_EFI enum entry into
two, as is done for other architectures.

Signed-off-by: Derek Foreman <derek@endlessos.org>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
grub-core/commands/file.c

index 2574e66859a2d938d25c959f1d76fa9b6d2c4af0..9de00061eb5414ae38d8bd5b696221df303aa642 100644 (file)
@@ -134,7 +134,8 @@ enum
   IS_IA_EFI,
   IS_ARM64_EFI,
   IS_ARM_EFI,
-  IS_RISCV_EFI,
+  IS_RISCV32_EFI,
+  IS_RISCV64_EFI,
   IS_HIBERNATED,
   IS_XNU64,
   IS_XNU32,
@@ -576,7 +577,8 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
     case IS_IA_EFI:
     case IS_ARM64_EFI:
     case IS_ARM_EFI:
-    case IS_RISCV_EFI:
+    case IS_RISCV32_EFI:
+    case IS_RISCV64_EFI:
       {
        char signature[4];
        grub_uint32_t pe_offset;
@@ -622,13 +624,13 @@ grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
            && coff_head.machine !=
            grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_ARMTHUMB_MIXED))
          break;
-       if (type == IS_RISCV_EFI
+       if ((type == IS_RISCV32_EFI || type == IS_RISCV64_EFI)
            && coff_head.machine !=
            grub_cpu_to_le16_compile_time (GRUB_PE32_MACHINE_RISCV64))
           /* TODO: Determine bitness dynamically */
          break;
        if (type == IS_IA_EFI || type == IS_64_EFI || type == IS_ARM64_EFI ||
-           type == IS_RISCV_EFI)
+           type == IS_RISCV32_EFI || type == IS_RISCV64_EFI)
          {
            struct grub_pe64_optional_header o64;
            if (grub_file_read (file, &o64, sizeof (o64)) != sizeof (o64))