]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg/PlatformPeiLib: add dummy assignment to work around older GCC
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 25 Mar 2020 09:30:07 +0000 (10:30 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 26 Mar 2020 08:09:53 +0000 (08:09 +0000)
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>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c

index 8b5b3dd5dc1cd93b9ba0cfa456a941de98e7ddef..6c4028e179955d896f7624b93b1ea7f27266b19e 100644 (file)
@@ -77,6 +77,11 @@ PlatformPeim (
 \r
   TpmBase = 0;\r
 \r
+  //\r
+  // Set Parent to suppress incorrect compiler/analyzer warnings.\r
+  //\r
+  Parent = 0;\r
+\r
   for (Prev = Depth = 0;; Prev = Node) {\r
     Node = fdt_next_node (Base, Prev, &Depth);\r
     if (Node < 0) {\r