[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/3] xen/efi: fix unitialized use warning


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Fri, 14 Apr 2023 14:57:13 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Op4gLrZXr+32HM/wsQS2QIeYqXOraK+iVo5JPJFoRrg=; b=PF0tw8puEGB7V1u4jMXk65LW/+c6OHWy94UvCCX/kPCviDxl6+UFeEWStJniZa2cg8W3tp1zKG7V3uWAoXQK4FZB4G0y7GpFHVfO8PAeiv2epeGIzj61IjIBjsC+07sF7YUkgoE44KPdH11MKPAGqVEYhzrrqAvAUxEcFCMRw+JYqfLYkHxAOitSo5xv5y+NFijKm04vtBHvRtmVMdTt4WZ7344MGK4pFBbQTPimQqDbabxDYqXnwqi8RKQG0HvhpbrZzoTSt7EFu8r+2sDHUREZhXqLQiDnNBttNMaphFyKPO2PXDdkRBa8R044Vh1iOz1RF2YXf/fjTh4z5iwYkQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aPo3Zkau8v5cZvvTDRT5ZDoJxjWnp46Q/ftxQaGfnfgX64fe8jZa27ISThGxZfFgj2URL0unFqPXgPe7IYajX6mvs0y9CnmofDz+hTxT2aMt+8tvYfRIkoMfX84Qaa9mSH0bLdg94thJl1E1KijBSopNwkjP+oEzi2G4MEuHaXvigdpZ3c9lgiB1uTlUJWxoIIB19nxXcMZQ75a4ZXQVNfm3hB09UuYDdjm812tQjxbPqSPVyRNStF6noawt1cdIWCThivdjFAZ0Vqp8dgQc+DnxVlOiEyq/4Vt/mzCb3WGkcWqYsTOqmBkLvfcs9w7bNuhI4RzzWJpYIIvPka0d8w==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 14 Apr 2023 18:58:17 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

When building the hypervisor for arm64 with -Og, we encounter a (false)
uninitialized use warning:

arch/arm/efi/boot.c: In function ‘efi_start’:
arch/arm/efi/boot.c:1468:9: error: ‘argc’ may be used uninitialized 
[-Werror=maybe-uninitialized]
 1468 |         efi_arch_handle_cmdline(argc ? *argv : NULL, options, name.s);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm/efi/boot.c:1263:21: note: ‘argc’ was declared here
 1263 |     unsigned int i, argc;
      |                     ^~~~
cc1: all warnings being treated as errors

Fix this by initializing argc. As a precaution, also initialize argv.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
See previous discussion here
https://lists.xenproject.org/archives/html/xen-devel/2022-10/msg00805.html
---
 xen/common/efi/boot.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/xen/common/efi/boot.c b/xen/common/efi/boot.c
index b69c83e354ee..c5850c26af9f 100644
--- a/xen/common/efi/boot.c
+++ b/xen/common/efi/boot.c
@@ -1344,6 +1344,15 @@ efi_start(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE 
*SystemTable)
         if ( !base_video )
             efi_console_set_mode();
     }
+    else
+    {
+        /*
+         * Some compilers may emit a false "uninitialized use" warning for 
argc,
+         * so initialize argc/argv here to avoid the warning.
+         */
+        argc = 0;
+        argv = NULL;
+    }
 
     PrintStr(L"Xen " XEN_VERSION_STRING XEN_EXTRAVERSION
             " (c/s " XEN_CHANGESET ") EFI loader\r\n");
-- 
2.40.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.