On Thu, 2017-09-07 at 09:48 -0500, miny...@acm.org wrote:
> From: Corey Minyard <cminy...@mvista.com>

So, what's wrong with %pU ?

I would rather NAK this until there is a strong argument to have such
code.

> 
> Cc: Christoph Hellwig <h...@lst.de>
> Cc: Andy Shevchenko <andriy.shevche...@linux.intel.com>
> Signed-off-by: Corey Minyard <cminy...@mvista.com>
> ---
>  include/linux/uuid.h |  7 +++++++
>  lib/uuid.c           | 28 ++++++++++++++++++++++++++++
>  2 files changed, 35 insertions(+)
> 
> diff --git a/include/linux/uuid.h b/include/linux/uuid.h
> index 33b0bdb..ab8ce39 100644
> --- a/include/linux/uuid.h
> +++ b/include/linux/uuid.h
> @@ -83,6 +83,13 @@ extern const u8 uuid_index[16];
>  int guid_parse(const char *uuid, guid_t *u);
>  int uuid_parse(const char *uuid, uuid_t *u);
>  
> +/*
> + * Returns the number of bytes put into the string, not including the
> + * terminating null byte.
> + */
> +int guid_to_str(char *str, unsigned int len, const guid_t *guid);
> +int uuid_to_str(char *str, unsigned int len, const uuid_t *uuid);
> +
>  /* backwards compatibility, don't use in new code */
>  #define uuid_le_gen(u)               guid_gen(u)
>  #define uuid_le_to_bin(guid, u)      guid_parse(guid, u)
> diff --git a/lib/uuid.c b/lib/uuid.c
> index 680b9fb..0ea6dd9 100644
> --- a/lib/uuid.c
> +++ b/lib/uuid.c
> @@ -129,3 +129,31 @@ int uuid_parse(const char *uuid, uuid_t *u)
>       return __uuid_parse(uuid, u->b, uuid_index);
>  }
>  EXPORT_SYMBOL(uuid_parse);
> +
> +static int __uuid_to_str(char *str, unsigned int len, const __u8
> b[16],
> +                      const u8 ei[16])
> +{
> +     unsigned int rv;
> +
> +     rv = snprintf(str, len,
> +                   "%2.2x%2.2x%2.2x%2.2x-%2.2x%2.2x-%2.2x%2.2x-
> %2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x",
> +                     b[ei[0]], b[ei[1]], b[ei[2]], b[ei[3]],
> +                     b[ei[4]], b[ei[5]], b[ei[6]], b[ei[7]],
> +                     b[ei[8]], b[ei[9]], b[ei[10]], b[ei[11]],
> +                     b[ei[12]], b[ei[13]], b[ei[14]], b[ei[15]]);
> +     if (rv >= len)
> +             rv = len - 1;
> +     return rv;
> +}
> +
> +int guid_to_str(char *str, unsigned int len, const guid_t *guid)
> +{
> +     return __uuid_to_str(str, len, guid->b, guid_index);
> +}
> +EXPORT_SYMBOL(guid_to_str);
> +
> +int uuid_to_str(char *str, unsigned int len, const uuid_t *uuid)
> +{
> +     return __uuid_to_str(str, len, uuid->b, uuid_index);
> +}
> +EXPORT_SYMBOL(uuid_to_str);

-- 
Andy Shevchenko <andriy.shevche...@linux.intel.com>
Intel Finland Oy

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to