grub-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v5 13/16] fs/f2fs: Simplify to use grub_utf16_to_utf8_alloc()


From: Vitaly Kuzmichev
Subject: Re: [PATCH v5 13/16] fs/f2fs: Simplify to use grub_utf16_to_utf8_alloc()
Date: Wed, 23 Aug 2023 12:39:48 +0000

Hi Vladimir,

On Tue, 2023-08-22 at 23:56 +0200, Vladimir 'phcoder' Serbinenko wrote:
> Same as other similar patches: maybe change call sites and remove
> function altogether?

Yes, for f2fs module we can do this. There is only one usage of the
function grub_f2fs_utf16_to_utf8, so no code duplication of inline
functions.


Best Regards,
Vitaly.

> 
> Le mar. 22 août 2023, 23:41, Vitaly Kuzmichev
> <vitaly.kuzmichev@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.kuzmichev@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;
> > 
> > _______________________________________________
> > Grub-devel mailing list
> > Grub-devel@gnu.org
> > https://lists.gnu.org/mailman/listinfo/grub-devel


reply via email to

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