Message ID | 20230414185714.292881-3-stewart.hildebrand@amd.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | xen/arm: fix build errors with -Og | expand |
On 14.04.2023 20:57, Stewart Hildebrand wrote: > 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. I'm not happy about this kind of change, and I also wonder whether we wouldn't better use initializers for both variables if we already have to work around compiler shortcomings like this one. Nevertheless I can see the need, so ... > Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com> Acked-by: Jan Beulich <jbeulich@suse.com> Jan
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");
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> --- 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(+)