[edk2-devel] [PATCH] OvmfPkg/EnrollDefaultKeys: suppress incorrect compiler warning

Laszlo Ersek lersek at redhat.com
Tue Apr 30 21:33:39 UTC 2019


When building OvmfPkg/EnrollDefaultKeys for IA32 with gcc-4.8 for the
DEBUG target (and possibly under other build configurations too), the
compiler incorrectly reports,

> OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c: In function
> 'ShellAppMain':
> OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c:631:10: error:
> 'SizeOfPkKek1' may be used uninitialized in this function
> [-Werror=maybe-uninitialized]
>    Status = EnrollListOfCerts (
>           ^
> OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c:703:12: error: 'PkKek1'
> may be used uninitialized in this function [-Werror=maybe-uninitialized]
>    FreePool (PkKek1);
>             ^
> cc1: all warnings being treated as errors

Suppress this warning, in the style suggested under
<https://bugzilla.tianocore.org/show_bug.cgi?id=607>.

Cc: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Cc: Jordan Justen <jordan.l.justen at intel.com>
Reported-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Fixes: be9470b3c91fc50436c15a76c85cdde940355b9f
Signed-off-by: Laszlo Ersek <lersek at redhat.com>
---
 OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
index b7b2e424c59e..75f2749dc84a 100644
--- a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
+++ b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
@@ -554,14 +554,21 @@ ShellAppMain (
   PrintSettings (&Settings);
 
   if (Settings.SetupMode != 1) {
     AsciiPrint ("error: already in User Mode\n");
     return RetVal;
   }
 
+  //
+  // Set PkKek1 and SizeOfPkKek1 to suppress incorrect compiler/analyzer
+  // warnings.
+  //
+  PkKek1 = NULL;
+  SizeOfPkKek1 = 0;
+
   //
   // Fetch the X509 certificate (to be used as Platform Key and first Key
   // Exchange Key) from SMBIOS.
   //
   Status = GetPkKek1 (&PkKek1, &SizeOfPkKek1);
   if (EFI_ERROR (Status)) {
     return RetVal;
-- 
2.19.1.3.g30247aa5d201


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

View/Reply Online (#39881): https://edk2.groups.io/g/devel/message/39881
Mute This Topic: https://groups.io/mt/31425619/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