]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/X86QemuLoadImageLib: fix "unused variable" error in X64 DXE builds
authorLaszlo Ersek <lersek@redhat.com>
Fri, 6 Mar 2020 23:04:42 +0000 (00:04 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sun, 8 Mar 2020 19:45:39 +0000 (19:45 +0000)
When the MDE_CPU_IA32 macro is not defined, there is no access to the
"KernelImageHandle" local variable in QemuStartKernelImage(). This breaks
the OvmfPkgIa32X64 and OvmfPkgX64 platform builds, at least with gcc-8.

Move the local variable to the inner scope, where declaration and usage
are inseparable.

(Note that such inner-scope declarations are frowned upon in the wider
edk2 codebase, but we use them liberally in ArmVirtPkg and OvmfPkg anyway,
because they help us reason about variable lifetime and visibility.)

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Fixes: 7c47d89003a6f8f7f6f0ce8ca7d3e87c630d14cc
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2572
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c

index c5bd6862b2651bf48aca3079f093cbdf7660ca88..1868c9fcafdf3642ad6eb101d37b1721dd7e585c 100644 (file)
@@ -460,7 +460,6 @@ QemuStartKernelImage (
 {\r
   EFI_STATUS                    Status;\r
   OVMF_LOADED_X86_LINUX_KERNEL  *LoadedImage;\r
-  EFI_HANDLE                    KernelImageHandle;\r
 \r
   Status = gBS->OpenProtocol (\r
                   *ImageHandle,\r
@@ -481,6 +480,8 @@ QemuStartKernelImage (
                   );\r
 #ifdef MDE_CPU_IA32\r
   if (Status == EFI_UNSUPPORTED) {\r
+    EFI_HANDLE KernelImageHandle;\r
+\r
     //\r
     // On IA32, EFI_UNSUPPORTED means that the image's machine type is X64 while\r
     // we are expecting a IA32 one, and the StartImage () boot service is unable\r