From owner-svn-src-head@freebsd.org Tue Jun 13 00:21:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0D137D874B2; Tue, 13 Jun 2017 00:21:03 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qt0-x22e.google.com (mail-qt0-x22e.google.com [IPv6:2607:f8b0:400d:c0d::22e]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CA587AFC; Tue, 13 Jun 2017 00:21:02 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-qt0-x22e.google.com with SMTP id u12so149170002qth.0; Mon, 12 Jun 2017 17:21:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=4ERK1Bvr2gBWQukTrvm87HrP0QsrGSZqAofVg28wSfM=; b=dbwP5gSb939aD6kMsuhLzmqun2qKAkkHmWOH5vFbcytdLZ9/+Ct/0tTvYoYS6XXt4Y WciZYwc3qAQTQUSuz9MqhrexAna36WghovPvSAkn8sR2Wm+B2lZABUa40f51xr6M71Ad 1s8OdE2U82KgPc9AzG+Rx421nYEdR8F2a9TAULcgTAdbbrDOo2j5fW049/eP3QLiwMsQ LxhTtZLcFVJwkiA1Zi/69kjxQIF8+F+smgKOajk+jxRuOQ6yfF2HMQgACCFYg2lweQH5 IYSr6YlTXWphL5h9MMtdBQTrLdiWKIfw5s5I28CXRbLl2lA85EA5kp3GrGJRH56m9kSD zJjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=4ERK1Bvr2gBWQukTrvm87HrP0QsrGSZqAofVg28wSfM=; b=TbstLFRk5FYPCMpHE0CML9V5xcuMjESZekqr2cJwTYbYaGcqKM/PK3xxPD8jsqzezd f5qQ78Y7T4ekp7Z0aXi8I+uo1H/9LNpVYzTLyT2aGpxGesAAqNjlrW0xLptlVJd2XPQ7 96exI46AofACCDjWV6hmu22XjgtpkdIJBipVjeBsySRrYv/HzU/+APx+nGzCMQ2+kueV 1rVLHKDDLZVlA0IppPnnuTIW7vND4L/JTkkjdjdNhG6H8o0d1euSpXo1qQCYseZToTPq Ry+CwzGw8WXtQ0wol0Y+QhSNGjCAOhqcMTLd8k8/Zdr9rj9fm3TYH2W1xE82VgvEvgy9 yZ1Q== X-Gm-Message-State: AKS2vOx2lLDt02oTMEicIeLguBASfGvj0sZDUjTqG9LVTf+4xMlOeVMm 0mlrSAyWmpQRYQ== X-Received: by 10.200.41.213 with SMTP id 21mr11922242qtt.168.1497313261912; Mon, 12 Jun 2017 17:21:01 -0700 (PDT) Received: from wkstn-mjohnston.west.isilon.com (c-76-104-201-218.hsd1.wa.comcast.net. [76.104.201.218]) by smtp.gmail.com with ESMTPSA id t42sm7601265qtg.43.2017.06.12.17.21.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Jun 2017 17:21:01 -0700 (PDT) Sender: Mark Johnston Date: Mon, 12 Jun 2017 17:20:52 -0700 From: Mark Johnston To: Konstantin Belousov Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r319868 - in head/sys: kern sys Message-ID: <20170613002052.GC73695@wkstn-mjohnston.west.isilon.com> References: <201706122014.v5CKEitK071089@repo.freebsd.org> <20170612202952.GU2088@kib.kiev.ua> <20170612204704.GA73695@wkstn-mjohnston.west.isilon.com> <20170612213300.GV2088@kib.kiev.ua> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170612213300.GV2088@kib.kiev.ua> User-Agent: Mutt/1.8.2 (2017-04-18) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 13 Jun 2017 00:21:03 -0000 On Tue, Jun 13, 2017 at 12:33:00AM +0300, Konstantin Belousov wrote: > On Mon, Jun 12, 2017 at 01:47:05PM -0700, Mark Johnston wrote: > > 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. > > I agree, your addition is consistent with the other code in kern_uuid.c, > which already depends on these features. At least it contradicts > to what compiler authors try to teach C language users. > > BTW, does uuid_private low/mid/hi union split of ll depend on endianess ? It seems so. The current usage is ok because the two representations aren't mixed. That is, ll is only used to access the time fields of the global uuid_last, and the low/mid/hi fields are never used with uuid_last. It does look like a bit of a landmine though; I think it would be worth adding a small hint: diff --git a/sys/kern/kern_uuid.c b/sys/kern/kern_uuid.c index 0953d901a592..78088e1c6f32 100644 --- a/sys/kern/kern_uuid.c +++ b/sys/kern/kern_uuid.c @@ -58,7 +58,7 @@ CTASSERT(sizeof(struct uuid) == 16); /* We use an alternative, more convenient representation in the generator. */ struct uuid_private { union { - uint64_t ll; /* internal. */ + uint64_t ll; /* internal, for uuid_last only */ struct { uint32_t low; uint16_t mid;