public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>, "Theodore Ts'o" <tytso@mit.edu>,
	Matt Fleming <matt@codeblueprint.co.uk>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org,
	linux-api@vger.kernel.org
Subject: Re: [PATCH v2 3/8] lib/uuid: introduce few more generic helpers for UUID
Date: Mon, 04 Apr 2016 16:55:50 -0700	[thread overview]
Message-ID: <1459814150.2138.3.camel@perches.com> (raw)
In-Reply-To: <20160404164029.9c72a93cb29d619766fbb2d2@linux-foundation.org>

On Mon, 2016-04-04 at 16:40 -0700, Andrew Morton wrote:
> On Mon,  4 Apr 2016 16:30:05 +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/include/linux/uuid.h
> > +++ b/include/linux/uuid.h
> Nit:
> 
> > 
> > +/**
> > +  * uuid_is_valid - checks if UUID string valid
> > +  * @uuid:	UUID string to check
> > +  *
> > +  * Description:
> > +  * It checks if the UUID string is following the format:
> > +  *	xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
> > +  * where x is a hex digit.
> > +  *
> > +  * Return: 0 on success, %-EINVAL otherwise.
> > +  */
> > +int uuid_is_valid(const char *uuid)
> > +{
> > +	unsigned int i;
> > +
> > +	if (strnlen(uuid, UUID_STRING_LEN) < UUID_STRING_LEN)
> > +		return -EINVAL;
> > +
> > +	for (i = 0; i < UUID_STRING_LEN; i++) {
> > +		if (i == 8 || i == 13 || i == 18 || i == 23) {
> > +			if (uuid[i] != '-')
> > +				return -EINVAL;
> > +		} else if (!isxdigit(uuid[i])) {
> > +			return -EINVAL;
> > +		}
> > +	}
> Could add
> 
> 	if (uuid[i])
> 		return -EINVAL;
> 
> here and lose the additional pass across the input (strlen).

nit2:

Could make this return bool.

  reply	other threads:[~2016-04-04 23:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-04 13:30 [PATCH v2 0/8] uuid: convert users to generic UUID API Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 1/8] lib/vsprintf: simplify UUID printing Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 2/8] lib/uuid: move generate_random_uuid() to uuid.c Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 3/8] lib/uuid: introduce few more generic helpers for UUID Andy Shevchenko
2016-04-04 23:40   ` Andrew Morton
2016-04-04 23:55     ` Joe Perches [this message]
2016-04-05  0:48     ` Stephen Rothwell
2016-04-05 10:51     ` Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 4/8] lib/uuid: remove FSF address Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 5/8] sysctl: drop away useless label Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 6/8] sysctl: use generic UUID library Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 7/8] efi: redefine type, constant, macro from generic code Andy Shevchenko
2016-04-04 13:30 ` [PATCH v2 8/8] efivars: use generic UUID library Andy Shevchenko
2016-04-04 23:40 ` [PATCH v2 0/8] uuid: convert users to generic UUID API Andrew Morton
2016-04-05 11:07   ` Andy Shevchenko
2016-04-05 14:06   ` Matt Fleming

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=1459814150.2138.3.camel@perches.com \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=arnd@arndb.de \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-efi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=matt@codeblueprint.co.uk \
    --cc=tytso@mit.edu \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox