Skip to contentSkip to conversation

xen/efi: Reduce variable scope to void compiler warning

PATCH In review Frediano Ziglio 3 participants 3 messages Jul 21, 2025 – Jul 29, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/efi: Reduce variable scope to void compiler warning

This change removes some pieve of code working around with some compiler warnings.
No functional change.

---
 xen/common/efi/boot.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
xen/common/efi/boot.c +4 -11
index 6c2ef13bc5..80d60ed54f 100644
@@ -1320,8 +1320,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
     static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID;
     EFI_LOADED_IMAGE *loaded_image;
     EFI_STATUS status;
-    unsigned int i, argc;
-    CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL;
+    unsigned int i;
+    CHAR16 *file_name, *cfg_file_name = NULL, *options = NULL;
     UINTN gop_mode = ~0;
     EFI_SHIM_LOCK_PROTOCOL *shim_lock;
     EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
@@ -1352,6 +1352,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
 
     if ( use_cfg_file )
     {
+        unsigned int argc;
+        CHAR16 **argv;
         UINTN offset = 0;
 
         argc = get_argv(0, NULL, loaded_image->LoadOptions,
@@ -1405,15 +1407,6 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
         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");
Signature · 1 line
2.43.0
Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Frediano Ziglio

This change removes some pieve of code working around with some compiler warnings.
No functional change.

Quoted 47 lines
---
 xen/common/efi/boot.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)
xen/common/efi/boot.c +4 -11
index 6c2ef13bc5..80d60ed54f 100644
@@ -1320,8 +1320,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
     static EFI_GUID __initdata shim_lock_guid = SHIM_LOCK_PROTOCOL_GUID;
     EFI_LOADED_IMAGE *loaded_image;
     EFI_STATUS status;
-    unsigned int i, argc;
-    CHAR16 **argv, *file_name, *cfg_file_name = NULL, *options = NULL;
+    unsigned int i;
+    CHAR16 *file_name, *cfg_file_name = NULL, *options = NULL;
     UINTN gop_mode = ~0;
     EFI_SHIM_LOCK_PROTOCOL *shim_lock;
     EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
@@ -1352,6 +1352,8 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
 
     if ( use_cfg_file )
     {
+        unsigned int argc;
+        CHAR16 **argv;
         UINTN offset = 0;
 
         argc = get_argv(0, NULL, loaded_image->LoadOptions,
@@ -1405,15 +1407,6 @@ void EFIAPI __init noreturn efi_start(EFI_HANDLE ImageHandle,
         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");
Signature · 1 line
2.43.0
Signature · 3 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab