linux16: Code cleanup

1. move relocator related code more close to each other
2. use variable "len" since it has correct assignment, and keep coding
style with upper code

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Cao jin 2018-08-07 14:57:53 +08:00 committed by Vincent Batts
parent eaf9cd2402
commit 3cf4158e6c

View file

@ -252,10 +252,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
(unsigned) real_size, (unsigned) real_size,
(unsigned) grub_linux16_prot_size); (unsigned) grub_linux16_prot_size);
relocator = grub_relocator_new ();
if (!relocator)
goto fail;
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
if (grub_memcmp (argv[i], "vga=", 4) == 0) if (grub_memcmp (argv[i], "vga=", 4) == 0)
{ {
@ -315,6 +311,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
} }
} }
relocator = grub_relocator_new ();
if (!relocator)
goto fail;
{ {
grub_relocator_chunk_t ch; grub_relocator_chunk_t ch;
err = grub_relocator_alloc_chunk_addr (relocator, &ch, err = grub_relocator_alloc_chunk_addr (relocator, &ch,
@ -367,8 +367,9 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
} }
len = grub_linux16_prot_size; len = grub_linux16_prot_size;
grub_memcpy (grub_linux_prot_chunk, kernel + kernel_offset, len); if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno)
kernel_offset += len; grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"),
argv[0]);
if (grub_errno == GRUB_ERR_NONE) if (grub_errno == GRUB_ERR_NONE)
{ {