efi_loader: use u16* for file name
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sat, 12 Jan 2019 11:02:33 +0000 (12:02 +0100)
committerAlexander Graf <agraf@suse.de>
Wed, 13 Feb 2019 08:40:06 +0000 (09:40 +0100)
UTF-16 strings in our code should all be u16 *. Fix an inconsistency for
file names which may lead to a warning for printf("%ls", ).

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
include/efi_api.h
lib/efi_loader/efi_file.c
lib/efi_selftest/efi_selftest_block_device.c

index 1d3774729dea277e6b94e871bd2263ecb5a6e2e2..d899af5e4870274f5a7a8f3ae5def6121058ef97 100644 (file)
@@ -909,7 +909,7 @@ struct efi_file_handle {
        u64 rev;
        efi_status_t (EFIAPI *open)(struct efi_file_handle *file,
                        struct efi_file_handle **new_handle,
-                       s16 *file_name, u64 open_mode, u64 attributes);
+                       u16 *file_name, u64 open_mode, u64 attributes);
        efi_status_t (EFIAPI *close)(struct efi_file_handle *file);
        efi_status_t (EFIAPI *delete)(struct efi_file_handle *file);
        efi_status_t (EFIAPI *read)(struct efi_file_handle *file,
index 8a4f3a9f408b0e7b894ead59244485c6536db9c1..9d709a8db026457480c8b79118423b45466004c7 100644 (file)
@@ -148,7 +148,7 @@ static int sanitize_path(char *path)
  * Returns:            handle to the opened file or NULL
  */
 static struct efi_file_handle *file_open(struct file_system *fs,
-               struct file_handle *parent, s16 *file_name, u64 mode,
+               struct file_handle *parent, u16 *file_name, u64 mode,
                u64 attributes)
 {
        struct file_handle *fh;
@@ -157,8 +157,8 @@ static struct efi_file_handle *file_open(struct file_system *fs,
        int flen = 0;
 
        if (file_name) {
-               utf16_to_utf8((u8 *)f0, (u16 *)file_name, 1);
-               flen = u16_strlen((u16 *)file_name);
+               utf16_to_utf8((u8 *)f0, file_name, 1);
+               flen = u16_strlen(file_name);
        }
 
        /* we could have a parent, but also an absolute path: */
@@ -183,7 +183,7 @@ static struct efi_file_handle *file_open(struct file_system *fs,
                        *p++ = '/';
                }
 
-               utf16_to_utf8((u8 *)p, (u16 *)file_name, flen);
+               utf16_to_utf8((u8 *)p, file_name, flen);
 
                if (sanitize_path(fh->path))
                        goto error;
@@ -216,7 +216,7 @@ error:
 
 static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file,
                struct efi_file_handle **new_handle,
-               s16 *file_name, u64 open_mode, u64 attributes)
+               u16 *file_name, u64 open_mode, u64 attributes)
 {
        struct file_handle *fh = to_fh(file);
        efi_status_t ret;
@@ -375,7 +375,7 @@ static efi_status_t dir_read(struct file_handle *fh, u64 *buffer_size,
        if (dent->type == FS_DT_DIR)
                info->attribute |= EFI_FILE_DIRECTORY;
 
-       ascii2unicode((u16 *)info->file_name, dent->name);
+       ascii2unicode(info->file_name, dent->name);
 
        fh->offset++;
 
@@ -666,7 +666,7 @@ struct efi_file_handle *efi_file_from_path(struct efi_device_path *fp)
                        return NULL;
                }
 
-               EFI_CALL(ret = f->open(f, &f2, (s16 *)fdp->str,
+               EFI_CALL(ret = f->open(f, &f2, fdp->str,
                                       EFI_FILE_MODE_READ, 0));
                if (ret != EFI_SUCCESS)
                        return NULL;
index f038da9f1909dc2869f666633996ec93524fda64..1cdd8307f4f1d0073409cea821a54b33fd46c551 100644 (file)
@@ -387,7 +387,7 @@ static int execute(void)
        }
 
        /* Read file */
-       ret = root->open(root, &file, (s16 *)L"hello.txt", EFI_FILE_MODE_READ,
+       ret = root->open(root, &file, L"hello.txt", EFI_FILE_MODE_READ,
                         0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");
@@ -431,7 +431,7 @@ static int execute(void)
 
 #ifdef CONFIG_FAT_WRITE
        /* Write file */
-       ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ |
+       ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ |
                         EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");
@@ -463,7 +463,7 @@ static int execute(void)
 
        /* Verify file */
        boottime->set_mem(buf, sizeof(buf), 0);
-       ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ,
+       ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ,
                         0);
        if (ret != EFI_SUCCESS) {
                efi_st_error("Failed to open file\n");