Same as other similar patches: maybe change call sites and remove function altogether?
Le mar. 22 août 2023, 23:41, Vitaly Kuzmichev <vitaly.kuzmic...@rtsoft.de> a écrit : > Transform grub_f2fs_utf16_to_utf8() function to use > grub_utf16_to_utf8_alloc() helper function to convert volume label > from UTF-16 to UTF-8. > > Signed-off-by: Vitaly Kuzmichev <vitaly.kuzmic...@rtsoft.de> > --- > grub-core/fs/f2fs.c | 24 +++++------------------- > 1 file changed, 5 insertions(+), 19 deletions(-) > > diff --git a/grub-core/fs/f2fs.c b/grub-core/fs/f2fs.c > index 429a3db83..827a8c196 100644 > --- a/grub-core/fs/f2fs.c > +++ b/grub-core/fs/f2fs.c > @@ -1251,25 +1251,10 @@ grub_f2fs_close (grub_file_t file) > return GRUB_ERR_NONE; > } > > -static grub_uint8_t * > -grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le) > +static char * > +grub_f2fs_utf16_to_utf8 (grub_uint16_t *in_buf_le, grub_size_t len) > { > - grub_uint16_t in_buf[MAX_VOLUME_NAME]; > - grub_uint8_t *out_buf; > - int len = 0; > - > - out_buf = grub_malloc (MAX_VOLUME_NAME * GRUB_MAX_UTF8_PER_UTF16 + 1); > - if (!out_buf) > - return NULL; > - > - while (*in_buf_le != 0 && len < MAX_VOLUME_NAME) { > - in_buf[len] = grub_le_to_cpu16 (in_buf_le[len]); > - len++; > - } > - > - *grub_utf16_to_utf8 (out_buf, in_buf, len, UTF16_CPU) = '\0'; > - > - return out_buf; > + return (char *) grub_utf16_to_utf8_alloc (in_buf_le, len, UTF16_LE); > } > > #if __GNUC__ >= 9 > @@ -1287,7 +1272,8 @@ grub_f2fs_label (grub_device_t device, char **label) > > data = grub_f2fs_mount (disk); > if (data) > - *label = (char *) grub_f2fs_utf16_to_utf8 (data->sblock.volume_name); > + *label = grub_f2fs_utf16_to_utf8 (data->sblock.volume_name, > + MAX_VOLUME_NAME); > else > *label = NULL; > > -- > 2.34.1 > > > _______________________________________________ > Grub-devel mailing list > Grub-devel@gnu.org > https://lists.gnu.org/mailman/listinfo/grub-devel >
_______________________________________________ Grub-devel mailing list Grub-devel@gnu.org https://lists.gnu.org/mailman/listinfo/grub-devel