From owner-svn-src-all@freebsd.org Wed Aug 2 13:55:02 2017 Return-Path: Delivered-To: svn-src-all@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 210B4DD15D1; Wed, 2 Aug 2017 13:55:02 +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 AB593658AF; Wed, 2 Aug 2017 13:55:01 +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 v72Dstw4052414 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 2 Aug 2017 16:54:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua v72Dstw4052414 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id v72DstPa052413; Wed, 2 Aug 2017 16:54:55 +0300 (EEST) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Wed, 2 Aug 2017 16:54:55 +0300 From: Konstantin Belousov To: Hans Petter Selasky Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r321920 - head/sys/sys Message-ID: <20170802135455.GG1700@kib.kiev.ua> References: <201708021014.v72AEHEk061037@repo.freebsd.org> <37abc595-c80e-a8da-04a8-815f42c634de@selasky.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <37abc595-c80e-a8da-04a8-815f42c634de@selasky.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-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Aug 2017 13:55:02 -0000 On Wed, Aug 02, 2017 at 02:38:50PM +0200, Hans Petter Selasky wrote: > On 08/02/17 14:36, Hans Petter Selasky wrote: > > On 08/02/17 12:14, Konstantin Belousov wrote: > >> +#define major(x) ((int)((dev_t)(x) >> 32)) /* major number */ > >> +#define minor(x) ((int)((x) & 0xffffffff)) /* minor number */ > >> +#define makedev(x, y) (((dev_t)(x) << 32) | (y)) /* create > >> dev_t */ > > > > One more comment on this issue: > > > > I think makedev(x, y) should be declared like this, to avoid issues when > > "y" is negative: > > > > #define makedev(x, y) (((dev_t)(x) << 32) | (unsigned int)(y)) > > /* create dev_t */ > > > > ??? > > > > --HPS > > > > > > And you'll probably want a final wrapping dev_t cast aswell. 128-bit > numbers are not yet there. > > #define makedev(x, y) ((dev_t)(((dev_t)(x) << 32) | (unsigned > int)(y))) > > /* create dev_t */ I agree with the usefulness of the y cast to unsigned type, but I am not sure what is the use of final dev_t cast. By the usual arithmetic conversion rules, the final type of the '|' is the highest rank type of the operands. Something unusual can only happen if int is wider than dev_t. So I am going to commit the following update. diff --git a/sys/sys/types.h b/sys/sys/types.h index fce57e412ed..30a08724443 100644 --- a/sys/sys/types.h +++ b/sys/sys/types.h @@ -366,7 +366,7 @@ __bitcount64(__uint64_t _x) #define major(x) ((int)((dev_t)(x) >> 32)) /* major number */ #define minor(x) ((int)((x) & 0xffffffff)) /* minor number */ -#define makedev(x, y) (((dev_t)(x) << 32) | (y)) /* create dev_t */ +#define makedev(x, y) (((dev_t)(x) << 32) | (unsigned)(y)) /* create dev_t */ /* * These declarations belong elsewhere, but are repeated here and in