efi: Use 16-bit unicode strings
At present we use wide characters for unicode but this is not necessary.
Change the code to use the 'u' literal instead. This helps to fix build
warnings for sandbox on rpi.
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
diff --git a/lib/efi_loader/efi_bootmgr.c b/lib/efi_loader/efi_bootmgr.c
index 1fe1923..8c04ecb 100644
--- a/lib/efi_loader/efi_bootmgr.c
+++ b/lib/efi_loader/efi_bootmgr.c
@@ -46,8 +46,8 @@
void **load_options)
{
struct efi_load_option lo;
- u16 varname[] = L"Boot0000";
- u16 hexmap[] = L"0123456789ABCDEF";
+ u16 varname[] = u"Boot0000";
+ u16 hexmap[] = u"0123456789ABCDEF";
void *load_option;
efi_uintn_t size;
efi_status_t ret;
@@ -83,7 +83,7 @@
attributes = EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS;
- ret = efi_set_variable_int(L"BootCurrent",
+ ret = efi_set_variable_int(u"BootCurrent",
&efi_global_variable_guid,
attributes, sizeof(n), &n, false);
if (ret != EFI_SUCCESS)
@@ -149,7 +149,7 @@
/* BootNext */
size = sizeof(bootnext);
- ret = efi_get_variable_int(L"BootNext",
+ ret = efi_get_variable_int(u"BootNext",
&efi_global_variable_guid,
NULL, &size, &bootnext, NULL);
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
@@ -158,7 +158,7 @@
log_err("BootNext must be 16-bit integer\n");
/* delete BootNext */
- ret = efi_set_variable_int(L"BootNext",
+ ret = efi_set_variable_int(u"BootNext",
&efi_global_variable_guid,
0, 0, NULL, false);
@@ -178,7 +178,7 @@
}
/* BootOrder */
- bootorder = efi_get_var(L"BootOrder", &efi_global_variable_guid, &size);
+ bootorder = efi_get_var(u"BootOrder", &efi_global_variable_guid, &size);
if (!bootorder) {
log_info("BootOrder not defined\n");
ret = EFI_NOT_FOUND;
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 37b9c68..1ea04de 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -3778,7 +3778,7 @@
.create_event_ex = efi_create_event_ex,
};
-static u16 __efi_runtime_data firmware_vendor[] = L"Das U-Boot";
+static u16 __efi_runtime_data firmware_vendor[] = u"Das U-Boot";
struct efi_system_table __efi_runtime_data systab = {
.hdr = {
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index 4463ae0..f4519c7 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -56,10 +56,10 @@
int i;
size = sizeof(value16);
- ret = efi_get_variable_int(L"CapsuleLast", &efi_guid_capsule_report,
+ ret = efi_get_variable_int(u"CapsuleLast", &efi_guid_capsule_report,
NULL, &size, value16, NULL);
if (ret != EFI_SUCCESS || size != 22 ||
- u16_strncmp(value16, L"Capsule", 7))
+ u16_strncmp(value16, u"Capsule", 7))
goto err;
for (i = 0; i < 4; ++i) {
u16 c = value16[i + 7];
@@ -113,14 +113,14 @@
}
/* Variable CapsuleLast must not include terminating 0x0000 */
- ret = efi_set_variable_int(L"CapsuleLast", &efi_guid_capsule_report,
+ ret = efi_set_variable_int(u"CapsuleLast", &efi_guid_capsule_report,
EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
22, variable_name16, false);
if (ret != EFI_SUCCESS)
- log_err("Setting %ls failed\n", L"CapsuleLast");
+ log_err("Setting %ls failed\n", u"CapsuleLast");
}
#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_MANAGEMENT
@@ -707,7 +707,7 @@
/* find active boot device in BootNext */
bootnext = 0;
size = sizeof(bootnext);
- ret = efi_get_variable_int(L"BootNext",
+ ret = efi_get_variable_int(u"BootNext",
(efi_guid_t *)&efi_global_variable_guid,
NULL, &size, &bootnext, NULL);
if (ret == EFI_SUCCESS || ret == EFI_BUFFER_TOO_SMALL) {
@@ -734,7 +734,7 @@
skip:
/* find active boot device in BootOrder */
size = 0;
- ret = efi_get_variable_int(L"BootOrder", &efi_global_variable_guid,
+ ret = efi_get_variable_int(u"BootOrder", &efi_global_variable_guid,
NULL, &size, NULL, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) {
boot_order = malloc(size);
@@ -743,7 +743,7 @@
goto out;
}
- ret = efi_get_variable_int(L"BootOrder",
+ ret = efi_get_variable_int(u"BootOrder",
&efi_global_variable_guid,
NULL, &size, boot_order, NULL);
}
@@ -875,8 +875,8 @@
break;
if (!(dirent->attribute & EFI_FILE_DIRECTORY) &&
- u16_strcmp(dirent->file_name, L".") &&
- u16_strcmp(dirent->file_name, L".."))
+ u16_strcmp(dirent->file_name, u".") &&
+ u16_strcmp(dirent->file_name, u".."))
tmp_files[count++] = u16_strdup(dirent->file_name);
}
/* ignore an error */
@@ -1052,7 +1052,7 @@
efi_status_t r;
size = sizeof(os_indications);
- r = efi_get_variable_int(L"OsIndications", &efi_global_variable_guid,
+ r = efi_get_variable_int(u"OsIndications", &efi_global_variable_guid,
NULL, &size, &os_indications, NULL);
if (r != EFI_SUCCESS || size != sizeof(os_indications))
return EFI_NOT_FOUND;
@@ -1061,7 +1061,7 @@
EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED) {
os_indications &=
~EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED;
- r = efi_set_variable_int(L"OsIndications",
+ r = efi_set_variable_int(u"OsIndications",
&efi_global_variable_guid,
EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index b80a6e0..802d39e 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -36,7 +36,7 @@
u16 *pos;
boot_current_size = sizeof(boot_current);
- ret = efi_get_variable_int(L"BootCurrent",
+ ret = efi_get_variable_int(u"BootCurrent",
&efi_global_variable_guid, NULL,
&boot_current_size, &boot_current, NULL);
if (ret != EFI_SUCCESS)
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index f43dfb3..f41cfa4 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -532,13 +532,13 @@
struct efi_signature_store *db = NULL, *dbx = NULL;
bool ret = false;
- dbx = efi_sigstore_parse_sigdb(L"dbx");
+ dbx = efi_sigstore_parse_sigdb(u"dbx");
if (!dbx) {
EFI_PRINT("Getting signature database(dbx) failed\n");
goto out;
}
- db = efi_sigstore_parse_sigdb(L"db");
+ db = efi_sigstore_parse_sigdb(u"db");
if (!db) {
EFI_PRINT("Getting signature database(db) failed\n");
goto out;
@@ -621,13 +621,13 @@
/*
* verify signature using db and dbx
*/
- db = efi_sigstore_parse_sigdb(L"db");
+ db = efi_sigstore_parse_sigdb(u"db");
if (!db) {
EFI_PRINT("Getting signature database(db) failed\n");
goto err;
}
- dbx = efi_sigstore_parse_sigdb(L"dbx");
+ dbx = efi_sigstore_parse_sigdb(u"dbx");
if (!dbx) {
EFI_PRINT("Getting signature database(dbx) failed\n");
goto err;
diff --git a/lib/efi_loader/efi_setup.c b/lib/efi_loader/efi_setup.c
index 380adc1..eee54e4 100644
--- a/lib/efi_loader/efi_setup.c
+++ b/lib/efi_loader/efi_setup.c
@@ -43,7 +43,7 @@
* Variable PlatformLangCodes defines the language codes that the
* machine can support.
*/
- ret = efi_set_variable_int(L"PlatformLangCodes",
+ ret = efi_set_variable_int(u"PlatformLangCodes",
&efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
@@ -57,7 +57,7 @@
* Variable PlatformLang defines the language that the machine has been
* configured for.
*/
- ret = efi_get_variable_int(L"PlatformLang",
+ ret = efi_get_variable_int(u"PlatformLang",
&efi_global_variable_guid,
NULL, &data_size, &pos, NULL);
if (ret == EFI_BUFFER_TOO_SMALL) {
@@ -74,7 +74,7 @@
if (pos)
*pos = 0;
- ret = efi_set_variable_int(L"PlatformLang",
+ ret = efi_set_variable_int(u"PlatformLang",
&efi_global_variable_guid,
EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
@@ -100,7 +100,7 @@
};
efi_status_t ret;
- ret = efi_set_variable_int(L"SignatureSupport",
+ ret = efi_set_variable_int(u"SignatureSupport",
&efi_global_variable_guid,
EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
@@ -129,12 +129,12 @@
efi_status_t ret = EFI_SUCCESS;
if (IS_ENABLED(CONFIG_EFI_HAVE_CAPSULE_UPDATE)) {
- ret = efi_set_variable_int(L"CapsuleMax",
+ ret = efi_set_variable_int(u"CapsuleMax",
&efi_guid_capsule_report,
EFI_VARIABLE_READ_ONLY |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
- 22, L"CapsuleFFFF", false);
+ 22, u"CapsuleFFFF", false);
if (ret != EFI_SUCCESS)
printf("EFI: cannot initialize CapsuleMax variable\n");
}
@@ -165,7 +165,7 @@
os_indications_supported |=
EFI_OS_INDICATIONS_FMP_CAPSULE_SUPPORTED;
- return efi_set_variable_int(L"OsIndicationsSupported",
+ return efi_set_variable_int(u"OsIndicationsSupported",
&efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
diff --git a/lib/efi_loader/efi_string.c b/lib/efi_loader/efi_string.c
index a3b8edf..8bf1e49 100644
--- a/lib/efi_loader/efi_string.c
+++ b/lib/efi_loader/efi_string.c
@@ -16,7 +16,7 @@
* @index: Index
*
* Create a utf-16 string with @name, appending @index.
- * For example, L"Capsule0001"
+ * For example, u"Capsule0001"
*
* The caller must ensure that the buffer has enough space for the resulting
* string including the trailing L'\0'.
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 0ae07ef..99ec3a5 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -1916,8 +1916,8 @@
{
u16 *boot_order;
u16 *boot_index;
- u16 var_name[] = L"BootOrder";
- u16 boot_name[] = L"Boot####";
+ u16 var_name[] = u"BootOrder";
+ u16 boot_name[] = u"Boot####";
u8 *bootvar;
efi_uintn_t var_data_size;
u32 count, i;
diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
index 9f1dd74..eb83702 100644
--- a/lib/efi_loader/efi_var_common.c
+++ b/lib/efi_loader/efi_var_common.c
@@ -229,26 +229,26 @@
efi_secure_boot = secure_boot;
- ret = efi_set_variable_int(L"SecureBoot", &efi_global_variable_guid,
+ ret = efi_set_variable_int(u"SecureBoot", &efi_global_variable_guid,
attributes_ro, sizeof(secure_boot),
&secure_boot, false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_int(L"SetupMode", &efi_global_variable_guid,
+ ret = efi_set_variable_int(u"SetupMode", &efi_global_variable_guid,
attributes_ro, sizeof(setup_mode),
&setup_mode, false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_int(L"AuditMode", &efi_global_variable_guid,
+ ret = efi_set_variable_int(u"AuditMode", &efi_global_variable_guid,
audit_mode || setup_mode ?
attributes_ro : attributes_rw,
sizeof(audit_mode), &audit_mode, false);
if (ret != EFI_SUCCESS)
goto err;
- ret = efi_set_variable_int(L"DeployedMode",
+ ret = efi_set_variable_int(u"DeployedMode",
&efi_global_variable_guid,
audit_mode || deployed_mode || setup_mode ?
attributes_ro : attributes_rw,
@@ -280,7 +280,7 @@
if (ret != EFI_SUCCESS)
goto err;
} else if (mode == EFI_MODE_AUDIT) {
- ret = efi_set_variable_int(L"PK", &efi_global_variable_guid,
+ ret = efi_set_variable_int(u"PK", &efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS,
0, NULL, false);
@@ -354,7 +354,7 @@
return ret;
/* As we do not provide vendor keys this variable is always 0. */
- ret = efi_set_variable_int(L"VendorKeys",
+ ret = efi_set_variable_int(u"VendorKeys",
&efi_global_variable_guid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index 5adc7f8..8ca2d85 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -145,15 +145,15 @@
case EFI_AUTH_VAR_PK:
case EFI_AUTH_VAR_KEK:
/* with PK */
- truststore = efi_sigstore_parse_sigdb(L"PK");
+ truststore = efi_sigstore_parse_sigdb(u"PK");
if (!truststore)
goto err;
break;
case EFI_AUTH_VAR_DB:
case EFI_AUTH_VAR_DBX:
/* with PK and KEK */
- truststore = efi_sigstore_parse_sigdb(L"KEK");
- truststore2 = efi_sigstore_parse_sigdb(L"PK");
+ truststore = efi_sigstore_parse_sigdb(u"KEK");
+ truststore2 = efi_sigstore_parse_sigdb(u"PK");
if (!truststore) {
if (!truststore2)
goto err;
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index a2c65e3..58931c4 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -588,7 +588,7 @@
if (alt_ret != EFI_SUCCESS)
goto out;
- if (!u16_strcmp(variable_name, L"PK"))
+ if (!u16_strcmp(variable_name, u"PK"))
alt_ret = efi_init_secure_state();
out:
free(comm_buf);
diff --git a/lib/efi_loader/helloworld.c b/lib/efi_loader/helloworld.c
index 33e4fbc..10666dc 100644
--- a/lib/efi_loader/helloworld.c
+++ b/lib/efi_loader/helloworld.c
@@ -34,7 +34,7 @@
*/
static void print_uefi_revision(void)
{
- u16 rev[] = L"0.0.0";
+ u16 rev[] = u"0.0.0";
rev[0] = (systable->hdr.revision >> 16) + '0';
rev[4] = systable->hdr.revision & 0xffff;
@@ -48,9 +48,9 @@
else
rev[3] = 0;
- con_out->output_string(con_out, L"Running on UEFI ");
+ con_out->output_string(con_out, u"Running on UEFI ");
con_out->output_string(con_out, rev);
- con_out->output_string(con_out, L"\r\n");
+ con_out->output_string(con_out, u"\r\n");
}
/**
@@ -65,15 +65,15 @@
if (!memcmp(&systable->tables[i].guid, &fdt_guid,
sizeof(efi_guid_t)))
con_out->output_string
- (con_out, L"Have device tree\r\n");
+ (con_out, u"Have device tree\r\n");
if (!memcmp(&systable->tables[i].guid, &acpi_guid,
sizeof(efi_guid_t)))
con_out->output_string
- (con_out, L"Have ACPI 2.0 table\r\n");
+ (con_out, u"Have ACPI 2.0 table\r\n");
if (!memcmp(&systable->tables[i].guid, &smbios_guid,
sizeof(efi_guid_t)))
con_out->output_string
- (con_out, L"Have SMBIOS table\r\n");
+ (con_out, u"Have SMBIOS table\r\n");
}
}
@@ -86,13 +86,13 @@
void print_load_options(struct efi_loaded_image *loaded_image)
{
/* Output the load options */
- con_out->output_string(con_out, L"Load options: ");
+ con_out->output_string(con_out, u"Load options: ");
if (loaded_image->load_options_size && loaded_image->load_options)
con_out->output_string(con_out,
(u16 *)loaded_image->load_options);
else
- con_out->output_string(con_out, L"<none>");
- con_out->output_string(con_out, L"\r\n");
+ con_out->output_string(con_out, u"<none>");
+ con_out->output_string(con_out, u"\r\n");
}
/**
@@ -108,21 +108,21 @@
efi_status_t ret;
if (!device_path) {
- con_out->output_string(con_out, L"<none>\r\n");
+ con_out->output_string(con_out, u"<none>\r\n");
return EFI_SUCCESS;
}
string = dp2txt->convert_device_path_to_text(device_path, true, false);
if (!string) {
con_out->output_string
- (con_out, L"Cannot convert device path to text\r\n");
+ (con_out, u"Cannot convert device path to text\r\n");
return EFI_OUT_OF_RESOURCES;
}
con_out->output_string(con_out, string);
- con_out->output_string(con_out, L"\r\n");
+ con_out->output_string(con_out, u"\r\n");
ret = boottime->free_pool(string);
if (ret != EFI_SUCCESS) {
- con_out->output_string(con_out, L"Cannot free pool memory\r\n");
+ con_out->output_string(con_out, u"Cannot free pool memory\r\n");
return ret;
}
return EFI_SUCCESS;
@@ -148,7 +148,7 @@
con_out = systable->con_out;
/* UEFI requires CR LF */
- con_out->output_string(con_out, L"Hello, world!\r\n");
+ con_out->output_string(con_out, u"Hello, world!\r\n");
print_uefi_revision();
print_config_tables();
@@ -158,7 +158,7 @@
(void **)&loaded_image);
if (ret != EFI_SUCCESS) {
con_out->output_string
- (con_out, L"Cannot open loaded image protocol\r\n");
+ (con_out, u"Cannot open loaded image protocol\r\n");
goto out;
}
print_load_options(loaded_image);
@@ -168,12 +168,12 @@
NULL, (void **)&device_path_to_text);
if (ret != EFI_SUCCESS) {
con_out->output_string
- (con_out, L"Cannot open device path to text protocol\r\n");
+ (con_out, u"Cannot open device path to text protocol\r\n");
goto out;
}
if (!loaded_image->device_handle) {
con_out->output_string
- (con_out, L"Missing device handle\r\n");
+ (con_out, u"Missing device handle\r\n");
goto out;
}
ret = boottime->handle_protocol(loaded_image->device_handle,
@@ -181,14 +181,14 @@
(void **)&device_path);
if (ret != EFI_SUCCESS) {
con_out->output_string
- (con_out, L"Missing device path for device handle\r\n");
+ (con_out, u"Missing device path for device handle\r\n");
goto out;
}
- con_out->output_string(con_out, L"Boot device: ");
+ con_out->output_string(con_out, u"Boot device: ");
ret = print_device_path(device_path, device_path_to_text);
if (ret != EFI_SUCCESS)
goto out;
- con_out->output_string(con_out, L"File path: ");
+ con_out->output_string(con_out, u"File path: ");
ret = print_device_path(loaded_image->file_path, device_path_to_text);
if (ret != EFI_SUCCESS)
goto out;