All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Dmitry Kasatkin
	<dmitry.kasatkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	Mimi Zohar
	<zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Andrew Morton
	<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
	Rasmus Villemoes
	<linux-qQsb+v5E8BnlAoU/VqSP6n9LOBIZ5rWg@public.gmane.org>,
	linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Matt Fleming
	<matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org>,
	Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>,
	Theodore Ts'o <tytso-3s7WtUTddSA@public.gmane.org>
Subject: Re: [PATCH v3 04/10] lib/uuid: introduce few more generic helpers for UUID
Date: Tue, 05 Apr 2016 17:15:58 +0300	[thread overview]
Message-ID: <1459865758.17884.19.camel@linux.intel.com> (raw)
In-Reply-To: <1459864579-55988-5-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>

On Tue, 2016-04-05 at 16:56 +0300, Andy Shevchenko wrote:
> There are new helpers in this patch:
> 
> uuid_is_valid		checks if a UUID is valid
> uuid_be_to_bin		converts from string to binary (big
> endian)
> uuid_le_to_bin		converts from string to binary (little
> endian)
> 
> They will be used in future, i.e. in the following patches in the
> series.
> 
> This also moves indices arrays to lib/uuid.c to be shared accross
> modules.
> 

> --- a/lib/uuid.c
> +++ b/lib/uuid.c

> +static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8
> ei[16])
> +{
> +	static const u8 si[16] =
> {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
> +	unsigned int i;
> +
> +	if (uuid_is_valid(uuid))

Oops, sorry, typo is here, should be negative check.

if (!uuid_is_valid(uuid))


> +		return -EINVAL;
> +
> +	for (i = 0; i < 16; i++) {
> +		int hi = hex_to_bin(uuid[si[i]] + 0);
> +		int lo = hex_to_bin(uuid[si[i]] + 1);
> +
> +		b[ei[i]] = (hi << 4) | lo;
> +	}
> +
> +	return 0;
> +}

-- 
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
Intel Finland Oy

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
	Mimi Zohar <zohar@linux.vnet.ibm.com>,
	linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-efi@vger.kernel.org,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Arnd Bergmann <arnd@arndb.de>, "Theodore Ts'o" <tytso@mit.edu>
Subject: Re: [PATCH v3 04/10] lib/uuid: introduce few more generic helpers for UUID
Date: Tue, 05 Apr 2016 17:15:58 +0300	[thread overview]
Message-ID: <1459865758.17884.19.camel@linux.intel.com> (raw)
In-Reply-To: <1459864579-55988-5-git-send-email-andriy.shevchenko@linux.intel.com>

On Tue, 2016-04-05 at 16:56 +0300, Andy Shevchenko wrote:
> There are new helpers in this patch:
> 
> uuid_is_valid		checks if a UUID is valid
> uuid_be_to_bin		converts from string to binary (big
> endian)
> uuid_le_to_bin		converts from string to binary (little
> endian)
> 
> They will be used in future, i.e. in the following patches in the
> series.
> 
> This also moves indices arrays to lib/uuid.c to be shared accross
> modules.
> 

> --- a/lib/uuid.c
> +++ b/lib/uuid.c

> +static int __uuid_to_bin(const char *uuid, __u8 b[16], const u8
> ei[16])
> +{
> +	static const u8 si[16] =
> {0,2,4,6,9,11,14,16,19,21,24,26,28,30,32,34};
> +	unsigned int i;
> +
> +	if (uuid_is_valid(uuid))

Oops, sorry, typo is here, should be negative check.

if (!uuid_is_valid(uuid))


> +		return -EINVAL;
> +
> +	for (i = 0; i < 16; i++) {
> +		int hi = hex_to_bin(uuid[si[i]] + 0);
> +		int lo = hex_to_bin(uuid[si[i]] + 1);
> +
> +		b[ei[i]] = (hi << 4) | lo;
> +	}
> +
> +	return 0;
> +}

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

  parent reply	other threads:[~2016-04-05 14:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-05 13:56 [PATCH v3 00/10] uuid: convert users to generic UUID API Andy Shevchenko
     [not found] ` <1459864579-55988-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-05 13:56   ` [PATCH v3 01/10] lib/vsprintf: simplify UUID printing Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
2016-04-05 13:56   ` [PATCH v3 02/10] ima: use %pU to output UUID in printable format Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
     [not found]     ` <1459864579-55988-3-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-05 23:16       ` Joe Perches
2016-04-05 23:16         ` Joe Perches
     [not found]         ` <1459898182.6715.22.camel-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
2016-04-06 11:02           ` Andy Shevchenko
2016-04-06 11:02             ` Andy Shevchenko
2016-04-05 13:56   ` [PATCH v3 04/10] lib/uuid: introduce few more generic helpers for UUID Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
     [not found]     ` <1459864579-55988-5-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-05 14:15       ` Andy Shevchenko [this message]
2016-04-05 14:15         ` Andy Shevchenko
2016-04-05 13:56   ` [PATCH v3 05/10] lib/uuid: remove FSF address Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
2016-04-05 13:56   ` [PATCH v3 06/10] sysctl: drop away useless label Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
     [not found]     ` <1459864579-55988-7-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2016-04-05 22:17       ` Andrew Morton
2016-04-05 22:17         ` Andrew Morton
     [not found]         ` <20160405151752.de82f221f1c70ff901b2b958-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>
2016-04-06 11:34           ` Andy Shevchenko
2016-04-06 11:34             ` Andy Shevchenko
2016-04-05 13:56   ` [PATCH v3 08/10] efi: redefine type, constant, macro from generic code Andy Shevchenko
2016-04-05 13:56     ` Andy Shevchenko
2016-04-05 13:56 ` [PATCH v3 03/10] lib/uuid: move generate_random_uuid() to uuid.c Andy Shevchenko
2016-04-05 13:56 ` [PATCH v3 07/10] sysctl: use generic UUID library Andy Shevchenko
2016-04-05 13:56 ` [PATCH v3 09/10] efivars: " Andy Shevchenko
2016-04-05 13:56 ` [PATCH v3 10/10] genhd: move to " Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1459865758.17884.19.camel@linux.intel.com \
    --to=andriy.shevchenko-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=dmitry.kasatkin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=linux-api-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-qQsb+v5E8BnlAoU/VqSP6n9LOBIZ5rWg@public.gmane.org \
    --cc=matt-mF/unelCI9GS6iBeEJttW/XRex20P6io@public.gmane.org \
    --cc=tytso-3s7WtUTddSA@public.gmane.org \
    --cc=zohar-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.