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

[xen master] xen/efi: fix uninitialized use warning



commit 7d5e60c525114c83e2ab8867297c1f9623b21ad5
Author:     Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
AuthorDate: Mon Apr 17 14:01:26 2023 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Apr 17 14:01:26 2023 +0200

    xen/efi: fix uninitialized use warning
    
    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>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 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 b69c83e354..c5850c26af 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");
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

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