grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 15/16] fs/iso9660: Simplify to use grub_utf16_to_utf8_alloc()


From: Vitaly Kuzmichev
Subject: [PATCH v5 15/16] fs/iso9660: Simplify to use grub_utf16_to_utf8_alloc()
Date: Tue, 22 Aug 2023 23:39:23 +0200

Transform grub_iso9660_convert_string() function to use
grub_utf16_to_utf8_alloc() helper function to convert file names and
volume name from UTF-16 to UTF-8.

Signed-off-by: Vitaly Kuzmichev <vitaly.kuzmichev@rtsoft.de>
---
 grub-core/fs/iso9660.c | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c
index 5eb6c1a0a..d2ea397ee 100644
--- a/grub-core/fs/iso9660.c
+++ b/grub-core/fs/iso9660.c
@@ -376,20 +376,7 @@ grub_iso9660_susp_iterate (grub_fshelp_node_t node, 
grub_off_t off,
 static char *
 grub_iso9660_convert_string (grub_uint8_t *us, int len)
 {
-  char *p;
-  int i;
-  grub_uint16_t t[MAX_NAMELEN / 2 + 1];
-
-  p = grub_calloc (len, GRUB_MAX_UTF8_PER_UTF16 + 1);
-  if (! p)
-    return NULL;
-
-  for (i=0; i<len; i++)
-    t[i] = grub_be_to_cpu16 (grub_get_unaligned16 (us + 2 * i));
-
-  *grub_utf16_to_utf8 ((grub_uint8_t *) p, t, len, UTF16_CPU) = '\0';
-
-  return p;
+  return (char *) grub_utf16_to_utf8_alloc (us, len, UTF16_BE);
 }
 
 static grub_err_t
-- 
2.34.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]