]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 25 Mar 2020 09:07:43 +0000 (10:07 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 26 Mar 2020 08:09:53 +0000 (08:09 +0000)
GCC 4.8 or 4.9 may throw the following error when building OVMF:

  Edk2/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c:
      In function ‘QemuLoadKernelImage’:
  Edk2/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c:416:30:
      error: ‘CommandLine’ may be used uninitialized in this function
                                               [-Werror=maybe-uninitialized]
        UnicodeSPrintAsciiFormat (
        cc1: all warnings being treated as errors

This is due to the fact that older GCCs fail to infer that CommandLine is
never actually used unless it has been assigned. So add a redundant NULL
assignment to help these older GCCs understand this.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2630
Fixes: 7c47d89003a6f ("OvmfPkg: implement QEMU loader library for X86 with ...")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c

index e52ec668f3751624522ac59a984fc119f0b558d1..ef753be7ea90324bcd42ae5a572fc0ba6240be9d 100644 (file)
@@ -291,6 +291,11 @@ QemuLoadKernelImage (
   CHAR8                     *CommandLine;\r
   UINTN                     InitrdSize;\r
 \r
+  //\r
+  // Redundant assignment to work around GCC48/GCC49 limitations.\r
+  //\r
+  CommandLine = NULL;\r
+\r
   //\r
   // Load the image. This should call back into the QEMU EFI loader file system.\r
   //\r