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

Older GCC (<= 4.9) fail to infer that Parent is never used unless it
has been assigned before, and may throw an error like

  /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:
      In function ‘PlatformPeim’:
  /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:132:24:
      error: ‘Parent’ may be used uninitialized in this function
                                                [-Werror=maybe-uninitialized]
             RangesProp = fdt_getprop (Base, Parent, "ranges", &RangesLen);

Set Parent to 0 at the start of the sequence to work around this.

Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2601
Fixes: 82662a3b5f56e974 ("ArmVirtPkg/PlatformPeiLib: discover the TPM base ...")
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
index 8b5b3dd5dc1c..6c4028e17995 100644
--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
+++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
@@ -77,6 +77,11 @@ PlatformPeim (
 
   TpmBase = 0;
 
+  //
+  // Set Parent to suppress incorrect compiler/analyzer warnings.
+  //
+  Parent = 0;
+
   for (Prev = Depth = 0;; Prev = Node) {
     Node = fdt_next_node (Base, Prev, &Depth);
     if (Node < 0) {
-- 
2.17.1


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

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

On 03/25/20 10:33, Ard Biesheuvel wrote:
> Older GCC (<= 4.9) fail to infer that Parent is never used unless it
> has been assigned before, and may throw an error like
> 
>   /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:
>       In function ‘PlatformPeim’:
>   /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:132:24:
>       error: ‘Parent’ may be used uninitialized in this function
>                                                 [-Werror=maybe-uninitialized]
>              RangesProp = fdt_getprop (Base, Parent, "ranges", &RangesLen);
> 
> Set Parent to 0 at the start of the sequence to work around this.
> 
> Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2601
> Fixes: 82662a3b5f56e974 ("ArmVirtPkg/PlatformPeiLib: discover the TPM base ...")
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
>  ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> index 8b5b3dd5dc1c..6c4028e17995 100644
> --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> @@ -77,6 +77,11 @@ PlatformPeim (
>  
>    TpmBase = 0;
>  
> +  //
> +  // Set Parent to suppress incorrect compiler/analyzer warnings.
> +  //
> +  Parent = 0;
> +
>    for (Prev = Depth = 0;; Prev = Node) {
>      Node = fdt_next_node (Base, Prev, &Depth);
>      if (Node < 0) {
> 

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks,
Laszlo


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

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

On Wed, 25 Mar 2020 at 20:11, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 03/25/20 10:33, Ard Biesheuvel wrote:
> > Older GCC (<= 4.9) fail to infer that Parent is never used unless it
> > has been assigned before, and may throw an error like
> >
> >   /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:
> >       In function ‘PlatformPeim’:
> >   /work/git/edk2/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c:132:24:
> >       error: ‘Parent’ may be used uninitialized in this function
> >                                                 [-Werror=maybe-uninitialized]
> >              RangesProp = fdt_getprop (Base, Parent, "ranges", &RangesLen);
> >
> > Set Parent to 0 at the start of the sequence to work around this.
> >
> > Link: https://bugzilla.tianocore.org/show_bug.cgi?id=2601
> > Fixes: 82662a3b5f56e974 ("ArmVirtPkg/PlatformPeiLib: discover the TPM base ...")
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> > ---
> >  ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> > index 8b5b3dd5dc1c..6c4028e17995 100644
> > --- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> > +++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
> > @@ -77,6 +77,11 @@ PlatformPeim (
> >
> >    TpmBase = 0;
> >
> > +  //
> > +  // Set Parent to suppress incorrect compiler/analyzer warnings.
> > +  //
> > +  Parent = 0;
> > +
> >    for (Prev = Depth = 0;; Prev = Node) {
> >      Node = fdt_next_node (Base, Prev, &Depth);
> >      if (Node < 0) {
> >
>
> 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:33 [PATCH] ArmVirtPkg/PlatformPeiLib: add dummy assignment to work around older GCC Ard Biesheuvel
2020-03-25 19:11 ` [edk2-devel] " Laszlo Ersek
2020-03-26  8:11   ` Ard Biesheuvel

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