svn commit: r319868 - in head/sys: kern sys

Mark Johnston markj at FreeBSD.org
Mon Jun 12 20:47:18 UTC 2017


On Mon, Jun 12, 2017 at 11:29:52PM +0300, Konstantin Belousov wrote:
> On Mon, Jun 12, 2017 at 08:14:44PM +0000, Mark Johnston wrote:
> > +int
> > +uuidcmp(const struct uuid *uuid1, const struct uuid *uuid2)
> > +{
> > +
> > +	return (memcmp(uuid1, uuid2, sizeof(struct uuid)));
> > +}
> 
> This is unsafe.  The function operation depends on the ABI properties
> that there is no padding either between members, or at the end of
> the structure.  Why not use by-member comparision ?

I interpreted the CTASSERT at the beginning of kern_uuid.c as a
guarantee that no such padding will be present. kern_uuid.c also defines
an alternate representation, struct uuid_private, and casts between the
two.


More information about the svn-src-head mailing list