[U-Boot] [RFC PATCH v2 1/8] uuid: add function for GUID string parsing

Simon Glass sjg at chromium.org
Thu Dec 1 03:21:06 CET 2016


Hi Patrick,

On 30 November 2016 at 04:01, Patrick Delaunay
<patrick.delaunay73 at gmail.com> wrote:
> Signed-off-by: Patrick Delaunay <patrick.delaunay at st.com>
> Signed-off-by: Patrick Delaunay <patrick.delaunay73 at gmail.com>
> ---
>
> Changes in v2:
> - split serie to reduce patches size
>   (seperate disk part and cmd impact and add precursor patch)
> - split large function
>
>  include/uuid.h |  1 +
>  lib/uuid.c     | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 34 insertions(+)

Reviewed-by: Simon Glass <sjg at chromium.org>

Nit below

>
> diff --git a/include/uuid.h b/include/uuid.h
> index c3f423f..f444095 100644
> --- a/include/uuid.h
> +++ b/include/uuid.h
> @@ -40,6 +40,7 @@ void uuid_bin_to_str(unsigned char *uuid_bin, char *uuid_str, int str_format);
>  int uuid_guid_get_bin(const char *guid_str, unsigned char *guid_bin);
>  int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str);
>  #endif
> +int uuid_guid_parse_str(const char *str, char *guid_str);
>  void gen_rand_uuid(unsigned char *uuid_bin);
>  void gen_rand_uuid_str(char *uuid_str, int str_format);
>  #endif
> diff --git a/lib/uuid.c b/lib/uuid.c
> index c8584ed..eb8d8eb 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -136,6 +136,39 @@ int uuid_guid_get_str(unsigned char *guid_bin, char *guid_str)
>  #endif
>
>  /*
> + * uuid_guid_parse_str() - this function parse string for GUID.

parses?

What exactly does it do to parse it? i.e. what is the purpose of this function?

> + *
> + * @param guid_str - pointer to string with partition type guid [37B]
> + *                   or GUID shorcut
> + * @param guid_str - pointer to allocated partition type string [37B]

Which one is the input param and which is the output. These comments
are a bit unclear.
> + */

@return ...(document return value)

> +int uuid_guid_parse_str(const char *str, char *guid_str)
> +{
> +#ifdef CONFIG_PARTITION_TYPE_GUID
> +       int i;
> +#endif
> +
> +       if (guid_str == NULL)
> +               return -ENODEV;
> +
> +       if (uuid_str_valid(str)) {
> +               memcpy(guid_str, str, UUID_STR_LEN + 1);
> +               return 0;
> +       }
> +
> +#ifdef CONFIG_PARTITION_TYPE_GUID
> +       for (i = 0; i < ARRAY_SIZE(list_guid); i++) {
> +               if (!strcmp(list_guid[i].string, str)) {
> +                       uuid_bin_to_str((unsigned char *)list_guid[i].guid.b,
> +                                       guid_str, UUID_STR_FORMAT_GUID);
> +                       return 0;
> +               }
> +       }
> +#endif
> +       return -ENODEV;
> +}
> +
> +/*
>   * uuid_str_to_bin() - convert string UUID or GUID to big endian binary data.
>   *
>   * @param uuid_str - pointer to UUID or GUID string [37B] or GUID shorcut
> --
> 1.9.1

Regards,
Simon


More information about the U-Boot mailing list