[edk2-devel] [PATCH] ArmVirtPkg/PlatformPeiLib: add dummy assignment to work around older GCC

Laszlo Ersek lersek at redhat.com
Wed Mar 25 19:11:10 UTC 2020


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 at 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 at redhat.com>

Thanks,
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#56338): https://edk2.groups.io/g/devel/message/56338
Mute This Topic: https://groups.io/mt/72537259/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list