grub-efi: fix the potential uninitialized error for variable 'err'

Fix the build errors with DEBUG_BUILD enabled:
  grub-core/loader/linux.c: In function 'grub_initrd_load':
  grub-core/loader/linux.c:326:10: error: 'err' may be used \
  uninitialized in this function [-Werror=maybe-uninitialized]

In function grub_initrd_load:
grub_initrd_load (struct grub_linux_initrd_context *initrd_ctx,
          char *argv[], void *target)
{
  [snip]
  grub_err_t err;
  [snip]

  #ifdef GRUB_MACHINE_EFI
      [snip]
      err = grub_verify_file (argv[i]);
      [snip]
  #endif

  [snip]
fail:
  [snip]
  return err;
}

If the GRUB_MACHINE_EFI is not defined, the function would return an
uninitialized value for 'err'. We should initialize it when this
variable is assigned.

Signed-off-by: Wenzong Fan <wenzong.fan@windriver.com>
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
This commit is contained in:
Wenzong Fan
2018-01-30 08:42:03 +00:00
committed by Jia Zhang
parent 22bd7aa878
commit dba3038152
@@ -451,7 +451,7 @@ index be6fa0f..edc6d24 100644
int newc = 0;
struct dir *root = 0;
grub_ssize_t cursize = 0;
+ grub_err_t err;
+ grub_err_t err = GRUB_ERR_NONE;
for (i = 0; i < initrd_ctx->nfiles; i++)
{