Mailing List Archive

[xen master] xen/efi: fix uninitialized use warning
commit 7d5e60c525114c83e2ab8867297c1f9623b21ad5
Author: Stewart Hildebrand <stewart.hildebrand@amd.com>
AuthorDate: Mon Apr 17 14:01:26 2023 +0200
Commit: Jan Beulich <jbeulich@suse.com>
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@amd.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
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