Re: [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC

Ard Biesheuvel

On Wed, 25 Mar 2020 at 20:08, Laszlo Ersek <> wrote:

On 03/25/20 10:12, Ard Biesheuvel wrote:
GCC 4.8 or 4.9 may throw the following error when building OVMF:

In function ‘QemuLoadKernelImage’:
error: ‘CommandLine’ may be used uninitialized in this function
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.

Fixes: 7c47d89003a6f ("OvmfPkg: implement QEMU loader library for X86 with ...")
Signed-off-by: Ard Biesheuvel <>
OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
index c5bd6862b265..52b14a4462d8 100644
--- a/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
+++ b/OvmfPkg/Library/X86QemuLoadImageLib/X86QemuLoadImageLib.c
@@ -291,6 +291,11 @@ QemuLoadKernelImage (
CHAR8 *CommandLine;
UINTN InitrdSize;

+ //
+ // Redundant assignment to work around GCC48/GCC49 limitations.
+ //
+ CommandLine = NULL;
// Load the image. This should call back into the QEMU EFI loader file system.
Reviewed-by: Laszlo Ersek <>
Pushed, thanks.

Join to automatically receive all group messages.