x86/xen/efi: Fix EFI variable 'name' type conversion
Subsystems (2)
PATCH 1/1 x86/xen/efi: Fix EFI variable 'name' type conversion
This resolves a type conversion from 'char *' to 'unsigned short'. and static usage warning as hinted by Sparse.
--- arch/x86/xen/efi.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/xen/efi.c +7 -7
@@ -118,8 +118,8 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void)unsigned long size; size =sizeof (secboot); - status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, -NULL , &size, &secboot); + status = efi.get_variable ((efi_char16_t *)L"SecureBoot" , + &efi_variable_guid,NULL , &size, &secboot);if (status ==EFI_NOT_FOUND )return efi_secureboot_mode_disabled;
@@ -128,8 +128,8 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void) goto out_efi_err; size =sizeof (setupmode); - status = efi.get_variable (L"SetupMode" , &efi_variable_guid, -NULL , &size, &setupmode); + status = efi.get_variable ((efi_char16_t *)L"SetupMode" , + &efi_variable_guid,NULL , &size, &setupmode);if (status !=EFI_SUCCESS ) goto out_efi_err;
@@ -139,8 +139,8 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void)/* See if a user has put the shim into insecure mode. */ size =sizeof (moksbstate); - status = efi.get_variable (L"MokSBStateRT" , &shim_guid, -NULL , &size, &moksbstate); + status = efi.get_variable ((efi_char16_t *)L"MokSBStateRT" , + &shim_guid,NULL , &size, &moksbstate);/* If it fails, we don't care why. Default to secure. */ if (status !=EFI_SUCCESS )
@@ -158,7 +158,7 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void)return efi_secureboot_mode_unknown; } -void __init xen_efi_init (struct boot_params *boot_params) +static void __init xen_efi_init (struct boot_params *boot_params) {efi_system_table_t *efi_systab_xen;
Signature · 1 line
2.21.0
Quoted 1 line · Adam Zerella
This resolves a type conversion from 'char *' to 'unsigned short'.
Could you explain this? There's no ...
arch/x86/xen/efi.c static enum efi_secureboot_mode xen_efi_get_secureboot(void) · line 122
Quoted 10 lines
arch/x86/xen/efi.c +2
-2@@ -118,8 +118,8 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void)unsigned long size; size =sizeof (secboot); - status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, -NULL , &size, &secboot); + status = efi.get_variable ((efi_char16_t *)L"SecureBoot" , + &efi_variable_guid,NULL , &size, &secboot);
... "char *" resulting as type for L"" type strings, hence there should be no need for a cast: In fact I consider such casts dangerous, as they may hide actual problems. To me this looks more like something that wants fixing in sparse; the compilers, after all, have no issue with such wide character string literals.
arch/x86/xen/efi.c static enum efi_secureboot_mode xen_efi_get_secureboot(void) · line 163
Quoted 8 lines
arch/x86/xen/efi.c +1
-1@@ -158,7 +158,7 @@ static enum efi_secureboot_mode xen_efi_get_secureboot(void)return efi_secureboot_mode_unknown; } -void __init xen_efi_init (struct boot_params *boot_params) +static void __init xen_efi_init (struct boot_params *boot_params) {efi_system_table_t *efi_systab_xen;
If I was a maintainer of this code, I'd request this not be part of a patch with a title being entirely unrelated to the change.
Jan
Ahh, I see that I definitely should have made the patch notes more descriptive. I could be wrong but I was under the impression that casting the data type of wchar_t to efi_char16_t (unsigned short) was acceptable as I've seen it in similar patches before, see here
https://lkml.org/lkml/2019/7/21/126. The Sparse warning threw me off.
I thought the cast would inform the compiler better when it came to unicode characters, I may be wrong here, I'm very new to submitting patches...
Quoted 37 lines · Jan Beulich
Quoted 1 line · Adam Zerella
This resolves a type conversion from 'char *' to 'unsigned short'.
Could you explain this? There's no ...
arch/x86/xen/efi.c static enum efi_secureboot_mode
Quoted 3 lines
arch/x86/xen/efi.c +0
-0@@ -118,8 +118,8 @@ static enum efi_secureboot_mode
xen_efi_get_secureboot(void)arch/x86/xen/efi.c static enum efi_secureboot_mode xen_efi_get_secureboot(void)
Quoted 7 lines
arch/x86/xen/efi.c +2
-2unsigned long size; size =sizeof (secboot); - status = efi.get_variable (L"SecureBoot" , &efi_variable_guid, -NULL , &size, &secboot); + status = efi.get_variable((efi_char16_t *)L"SecureBoot", + &efi_variable_guid, NULL, &size,&secboot);
... "char *" resulting as type for L"" type strings, hence there should be no need for a cast: In fact I consider such casts dangerous, as they may hide actual problems. To me this looks more like something that wants fixing in sparse; the compilers, after all, have no issue with such wide character string literals.
arch/x86/xen/efi.c static enum efi_secureboot_mode
Quoted 1 line
arch/x86/xen/efi.c +0
-0@@ -158,7 +158,7 @@ static enum efi_secureboot_mode
xen_efi_get_secureboot(void)arch/x86/xen/efi.c static enum efi_secureboot_mode xen_efi_get_secureboot(void) · line 163
Quoted 7 lines
arch/x86/xen/efi.c +1
-1return efi_secureboot_mode_unknown; } -void __init xen_efi_init (struct boot_params *boot_params) +static void __init xen_efi_init (struct boot_params *boot_params) {efi_system_table_t *efi_systab_xen;If I was a maintainer of this code, I'd request this not be part of a patch with a title being entirely unrelated to the change.
Quoted 2 lines
Jan
Adam
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel