From owner-svn-src-head@freebsd.org Sat Aug 5 07:42:55 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 239FBDC40DF; Sat, 5 Aug 2017 07:42:55 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id AAF4669A05; Sat, 5 Aug 2017 07:42:54 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id v757giLO034595 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Sat, 5 Aug 2017 10:42:44 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v757giLO034595 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v757ghK5034594; Sat, 5 Aug 2017 10:42:43 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Sat, 5 Aug 2017 10:42:43 +0300 From: Konstantin Belousov To: Bruce Evans Cc: Hans Petter Selasky , src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321920 - head/sys/sys Message-ID: <20170805074243.GX1700@kib.kiev.ua> References: <201708021014.v72AEHEk061037@repo.freebsd.org> <37abc595-c80e-a8da-04a8-815f42c634de@selasky.org> <20170802135455.GG1700@kib.kiev.ua> <20170803122015.Q1093@besplex.bde.org> <20170803075747.GJ1700@kib.kiev.ua> <20170803180419.R2314@besplex.bde.org> <20170803120729.GO1700@kib.kiev.ua> <20170805112924.W1055@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170805112924.W1055@besplex.bde.org> User-Agent: Mutt/1.8.3 (2017-05-23) X-Spam-Status: No, score=-2.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on tom.home 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: Sat, 05 Aug 2017 07:42:55 -0000 On Sat, Aug 05, 2017 at 12:26:03PM +1000, Bruce Evans wrote: > > +#define minor(x) ((int)(x)) > > Another nice simplification. Strictly, it should be (int)(dev_t)(x) since > the pseudo-prototype says that the arg is converted to dev_t, but yesterday > I couldn't see any differences even for exotic x and exotic arches. > > Today I can see some difference for exotic x and perverse implementations. > E.g., x with extra bits in a large signed integer type to invoke > implementation-defined behaviour, and a perverse implementation that > truncates to 0 for direct conversion to int but does the right thing > for indirect conversion). But we depend on the implementation doing > the right thing for other casts to int. > > Also, if dev_t == uintptr_t, it is valid for the caller to keep dev_t's > in void *'s internally but not to pass void * to minor() or major() > according to the prototype. However, casting in the macros breaks the > warning for this. I think pure macros should not cast their args or > pretend to have prototypes, but require callers to pass args of supported > types. The old dev_t macros were closer to this -- they have expressions > like ((x) << 8) which will fail if x is not an integral type or give > wrong results ix x has extra bits. So you are arguing to keep the & 0xffffffff operation ? I think this is not needed, since your note about cast being equivalent holds for all supported architectures and I do not see anywhere a contract for the operations to work on non-dev_t. So are you fine with the posted patch to sys/types.h ?