diff mbox series

[10/10] commands/file: use definitions from arm64/linux.h

Message ID 20180201181858.1472-11-leif.lindholm@linaro.org
State Superseded
Headers show
Series various cleanup | expand

Commit Message

Leif Lindholm Feb. 1, 2018, 6:18 p.m. UTC
Clean up code for matching IS_ARM64 slightly by making use of struct
linux_arm_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.

Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>

---
 grub-core/commands/file.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

-- 
2.11.0


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Comments

Daniel Kiper Feb. 15, 2018, 10:31 a.m. UTC | #1
On Thu, Feb 01, 2018 at 06:18:58PM +0000, Leif Lindholm wrote:
> Clean up code for matching IS_ARM64 slightly by making use of struct

> linux_arm_kernel_header and GRUB_LINUX_ARM64_MAGIC_SIGNATURE.

>

> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>


Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>


Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel
diff mbox series

Patch

diff --git a/grub-core/commands/file.c b/grub-core/commands/file.c
index fad191202..dd729a8a8 100644
--- a/grub-core/commands/file.c
+++ b/grub-core/commands/file.c
@@ -28,6 +28,7 @@ 
 #include <grub/xen_file.h>
 #include <grub/efi/pe32.h>
 #include <grub/arm/linux.h>
+#include <grub/arm64/linux.h>
 #include <grub/i386/linux.h>
 #include <grub/xnu.h>
 #include <grub/machoload.h>
@@ -404,13 +405,13 @@  grub_cmd_file (grub_extcmd_context_t ctxt, int argc, char **args)
       }
     case IS_ARM64_LINUX:
       {
-	grub_uint32_t sig;
+	struct linux_arm64_kernel_header lh;
 
-	if (grub_file_seek (file, 0x38) == (grub_size_t) -1)
-	  break;
-	if (grub_file_read (file, &sig, 4) != 4)
+	if (grub_file_read (file, &lh, sizeof (lh)) != sizeof (lh))
 	  break;
-	if (sig == grub_cpu_to_le32_compile_time (0x644d5241))
+
+	if (lh.magic ==
+	    grub_cpu_to_le32_compile_time (GRUB_LINUX_ARM64_MAGIC_SIGNATURE))
 	  {
 	    ret = 1;
 	    break;