From: Cao jin Date: Tue, 7 Aug 2018 06:57:53 +0000 (+0800) Subject: linux16: Code cleanup X-Git-Tag: grub-2.04-rc1~142 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d7d13ce44875289ac1b5034f311e047dfc62866;p=thirdparty%2Fgrub.git 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 Reviewed-by: Daniel Kiper --- diff --git a/grub-core/loader/i386/pc/linux.c b/grub-core/loader/i386/pc/linux.c index b69cb7a3a..531b58d37 100644 --- a/grub-core/loader/i386/pc/linux.c +++ b/grub-core/loader/i386/pc/linux.c @@ -236,10 +236,6 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), (unsigned) real_size, (unsigned) grub_linux16_prot_size); - relocator = grub_relocator_new (); - if (!relocator) - goto fail; - for (i = 1; i < argc; i++) if (grub_memcmp (argv[i], "vga=", 4) == 0) { @@ -299,6 +295,10 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } } + relocator = grub_relocator_new (); + if (!relocator) + goto fail; + { grub_relocator_chunk_t ch; err = grub_relocator_alloc_chunk_addr (relocator, &ch, @@ -355,8 +355,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), } len = grub_linux16_prot_size; - if (grub_file_read (file, grub_linux_prot_chunk, grub_linux16_prot_size) - != (grub_ssize_t) grub_linux16_prot_size && !grub_errno) + if (grub_file_read (file, grub_linux_prot_chunk, len) != len && !grub_errno) grub_error (GRUB_ERR_BAD_OS, N_("premature end of file %s"), argv[0]);