Commit c82f8f600a34d540f95a04e9cb3c49a9e6b3ae83
Committed by
Alexander Graf
1 parent
0bc81a717d
Exists in
smarc_8mq_lf_v2020.04
and in
11 other branches
efi_loader: use u16* for file name
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>
Showing 3 changed files with 11 additions and 11 deletions Side-by-side Diff
include/efi_api.h
... | ... | @@ -909,7 +909,7 @@ |
909 | 909 | u64 rev; |
910 | 910 | efi_status_t (EFIAPI *open)(struct efi_file_handle *file, |
911 | 911 | struct efi_file_handle **new_handle, |
912 | - s16 *file_name, u64 open_mode, u64 attributes); | |
912 | + u16 *file_name, u64 open_mode, u64 attributes); | |
913 | 913 | efi_status_t (EFIAPI *close)(struct efi_file_handle *file); |
914 | 914 | efi_status_t (EFIAPI *delete)(struct efi_file_handle *file); |
915 | 915 | efi_status_t (EFIAPI *read)(struct efi_file_handle *file, |
lib/efi_loader/efi_file.c
... | ... | @@ -148,7 +148,7 @@ |
148 | 148 | * Returns: handle to the opened file or NULL |
149 | 149 | */ |
150 | 150 | static struct efi_file_handle *file_open(struct file_system *fs, |
151 | - struct file_handle *parent, s16 *file_name, u64 mode, | |
151 | + struct file_handle *parent, u16 *file_name, u64 mode, | |
152 | 152 | u64 attributes) |
153 | 153 | { |
154 | 154 | struct file_handle *fh; |
... | ... | @@ -157,8 +157,8 @@ |
157 | 157 | int flen = 0; |
158 | 158 | |
159 | 159 | if (file_name) { |
160 | - utf16_to_utf8((u8 *)f0, (u16 *)file_name, 1); | |
161 | - flen = u16_strlen((u16 *)file_name); | |
160 | + utf16_to_utf8((u8 *)f0, file_name, 1); | |
161 | + flen = u16_strlen(file_name); | |
162 | 162 | } |
163 | 163 | |
164 | 164 | /* we could have a parent, but also an absolute path: */ |
... | ... | @@ -183,7 +183,7 @@ |
183 | 183 | *p++ = '/'; |
184 | 184 | } |
185 | 185 | |
186 | - utf16_to_utf8((u8 *)p, (u16 *)file_name, flen); | |
186 | + utf16_to_utf8((u8 *)p, file_name, flen); | |
187 | 187 | |
188 | 188 | if (sanitize_path(fh->path)) |
189 | 189 | goto error; |
... | ... | @@ -216,7 +216,7 @@ |
216 | 216 | |
217 | 217 | static efi_status_t EFIAPI efi_file_open(struct efi_file_handle *file, |
218 | 218 | struct efi_file_handle **new_handle, |
219 | - s16 *file_name, u64 open_mode, u64 attributes) | |
219 | + u16 *file_name, u64 open_mode, u64 attributes) | |
220 | 220 | { |
221 | 221 | struct file_handle *fh = to_fh(file); |
222 | 222 | efi_status_t ret; |
... | ... | @@ -375,7 +375,7 @@ |
375 | 375 | if (dent->type == FS_DT_DIR) |
376 | 376 | info->attribute |= EFI_FILE_DIRECTORY; |
377 | 377 | |
378 | - ascii2unicode((u16 *)info->file_name, dent->name); | |
378 | + ascii2unicode(info->file_name, dent->name); | |
379 | 379 | |
380 | 380 | fh->offset++; |
381 | 381 | |
... | ... | @@ -666,7 +666,7 @@ |
666 | 666 | return NULL; |
667 | 667 | } |
668 | 668 | |
669 | - EFI_CALL(ret = f->open(f, &f2, (s16 *)fdp->str, | |
669 | + EFI_CALL(ret = f->open(f, &f2, fdp->str, | |
670 | 670 | EFI_FILE_MODE_READ, 0)); |
671 | 671 | if (ret != EFI_SUCCESS) |
672 | 672 | return NULL; |
lib/efi_selftest/efi_selftest_block_device.c
... | ... | @@ -387,7 +387,7 @@ |
387 | 387 | } |
388 | 388 | |
389 | 389 | /* Read file */ |
390 | - ret = root->open(root, &file, (s16 *)L"hello.txt", EFI_FILE_MODE_READ, | |
390 | + ret = root->open(root, &file, L"hello.txt", EFI_FILE_MODE_READ, | |
391 | 391 | 0); |
392 | 392 | if (ret != EFI_SUCCESS) { |
393 | 393 | efi_st_error("Failed to open file\n"); |
... | ... | @@ -431,7 +431,7 @@ |
431 | 431 | |
432 | 432 | #ifdef CONFIG_FAT_WRITE |
433 | 433 | /* Write file */ |
434 | - ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ | | |
434 | + ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ | | |
435 | 435 | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE, 0); |
436 | 436 | if (ret != EFI_SUCCESS) { |
437 | 437 | efi_st_error("Failed to open file\n"); |
... | ... | @@ -463,7 +463,7 @@ |
463 | 463 | |
464 | 464 | /* Verify file */ |
465 | 465 | boottime->set_mem(buf, sizeof(buf), 0); |
466 | - ret = root->open(root, &file, (s16 *)L"u-boot.txt", EFI_FILE_MODE_READ, | |
466 | + ret = root->open(root, &file, L"u-boot.txt", EFI_FILE_MODE_READ, | |
467 | 467 | 0); |
468 | 468 | if (ret != EFI_SUCCESS) { |
469 | 469 | efi_st_error("Failed to open file\n"); |