lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1255684782.1951.28.camel@yhuang-dev.sh.intel.com>
Date:	Fri, 16 Oct 2009 17:19:42 +0800
From:	Huang Ying <ying.huang@...el.com>
To:	Laurent Pinchart <laurent.pinchart@...asonboard.com>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	Joe Perches <joe@...ches.com>,
	Steven Whitehouse <swhiteho@...hat.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [RFC 1/2] Unified UUID/GUID definition

On Fri, 2009-10-16 at 17:03 +0800, Laurent Pinchart wrote:
[...] 
> > +#define UUID_LE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> > +((uuid_le)								\
> > +{{ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff,
> >  \ +   (b) & 0xff, ((b) >> 8) & 0xff,					\
> > +   (c) & 0xff, ((c) >> 8) & 0xff,					\
> > +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
> > +
> > +#define UUID_BE(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7)		\
> > +((uuid_be)								\
> > +{{ ((a) >> 24) & 0xff, ((a) >> 16) & 0xff, ((a) >> 8) & 0xff, (a) & 0xff,
> >  \ +   ((b) >> 8) & 0xff, (b) & 0xff,					\
> > +   ((c) >> 8) & 0xff, (c) & 0xff,					\
> > +   (d0), (d1), (d2), (d3), (d4), (d5), (d6), (d7) }})
> > +
> > +#define NULL_UUID_LE							\
> > +	UUID_LE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> > +		0x00, 0x00, 0x00, 0x00)
> > +
> > +#define NULL_UUID_BE							\
> > +	UUID_BE(0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00,	\
> > +		0x00, 0x00, 0x00, 0x00)
> > +
> > +static inline int uuid_le_cmp(const uuid_le u1, const uuid_le u2)
> > +{
> > +	return memcmp(&u1, &u2, sizeof(uuid_le));
> > +}
> > +
> > +static inline int uuid_be_cmp(const uuid_be u1, const uuid_be u2)
> > +{
> > +	return memcmp(&u1, &u2, sizeof(uuid_be));
> > +}
> 
> Shouldn't you pass pointers to those functions instead ?

This is intended for a typical usage model (in fact copied from efi.h).

#define MY_UUID_LE	UUID_LE(...)

if (uuid_le_cmp(uuid, MY_UUID_LE)) {
	...
}

You need not define another variable for comparing with a UUID constant.

> It would also be nice to have a single uuid_cmp function. Would it be possible 
> to use typeof(), __builtin_types_compatible_p() and BUILD_BUG_ON_ZERO magic to 
> make sure both arguments are of the same type and one of uuid_be and uuid_le ? 
> It might no work with the Intel compiler though.

It seems a little tricky and complex. This is just a very simple
function.

Best Regards,
Huang Ying


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ