public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC
@ 2020-03-25  9:12 Ard Biesheuvel
  2020-03-25 19:08 ` [edk2-devel] " Laszlo Ersek
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-03-25  9:12 UTC (permalink / raw)
  To: devel; +Cc: lersek, Ard Biesheuvel

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>
---
 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.
   //
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC
  2020-03-25  9:12 [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC Ard Biesheuvel
@ 2020-03-25 19:08 ` Laszlo Ersek
  2020-03-26  8:10   ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Laszlo Ersek @ 2020-03-25 19:08 UTC (permalink / raw)
  To: devel, ard.biesheuvel

On 03/25/20 10:12, Ard Biesheuvel wrote:
> 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>
> ---
>  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 <lersek@redhat.com>

Thanks,
Laszlo


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [edk2-devel] [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC
  2020-03-25 19:08 ` [edk2-devel] " Laszlo Ersek
@ 2020-03-26  8:10   ` Ard Biesheuvel
  0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2020-03-26  8:10 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: edk2-devel-groups-io

On Wed, 25 Mar 2020 at 20:08, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 03/25/20 10:12, Ard Biesheuvel wrote:
> > 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>
> > ---
> >  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 <lersek@redhat.com>
>

Pushed, thanks.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-03-26  8:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-03-25  9:12 [PATCH] OvmfPkg/X86QemuLoadImageLib: add dummy assignment to work around GCC Ard Biesheuvel
2020-03-25 19:08 ` [edk2-devel] " Laszlo Ersek
2020-03-26  8:10   ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox