From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7A200C433FE for ; Thu, 17 Nov 2022 22:17:42 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4NCvRm6vd1z3dvn for ; Fri, 18 Nov 2022 09:17:40 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=aculab.com (client-ip=185.58.85.151; helo=eu-smtp-delivery-151.mimecast.com; envelope-from=david.laight@aculab.com; receiver=) Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4NCvR522gwz2yHc for ; Fri, 18 Nov 2022 09:17:04 +1100 (AEDT) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-135-r8pLcNsHMNSPwdstNZNmIw-1; Thu, 17 Nov 2022 22:15:38 +0000 X-MC-Unique: r8pLcNsHMNSPwdstNZNmIw-1 Received: from AcuMS.Aculab.com (10.202.163.4) by AcuMS.aculab.com (10.202.163.4) with Microsoft SMTP Server (TLS) id 15.0.1497.42; Thu, 17 Nov 2022 22:15:36 +0000 Received: from AcuMS.Aculab.com ([::1]) by AcuMS.aculab.com ([::1]) with mapi id 15.00.1497.044; Thu, 17 Nov 2022 22:15:36 +0000 From: David Laight To: 'Theodore Ts'o' , Kees Cook Subject: RE: [PATCH v2 3/3] treewide: use get_random_u32_between() when possible Thread-Topic: [PATCH v2 3/3] treewide: use get_random_u32_between() when possible Thread-Index: AQHY+pt8WAMBAHgXDk6lkwvXqmmyGK5DraKg Date: Thu, 17 Nov 2022 22:15:36 +0000 Message-ID: <5b2afac148e24181a206e540768e465b@AcuMS.aculab.com> References: <20221114164558.1180362-1-Jason@zx2c4.com> <20221114164558.1180362-4-Jason@zx2c4.com> <202211161436.A45AD719A@keescook> <202211161628.164F47F@keescook> <0EE39896-C7B6-4CB6-87D5-22AA787740A9@kernel.org> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Jason A. Donenfeld" , "Darrick J . Wong" , "linux-kernel@vger.kernel.org" , "netdev@vger.kernel.org" , Andreas Dilger , "ydroneaud@opteya.com" , Herbert Xu , Richard Weinberger , Helge Deller , Russell King , Jason Gunthorpe , Catalin Marinas , Jakub Kicinski , "linux-mips@vger.kernel.org" , "linux-media@vger.kernel.org" , Kees Cook , Heiko Carstens , Jani Nikula , "linux-block@vger.kernel.org" , SeongJae Park , "loongarch@lists.linux.dev" , Jaegeuk Kim , Thomas Gleixner , "linux-arm-kernel@lists.infradead.org" , Thomas Bogendoerfer , "linux-parisc@vger.kernel.org" , "Martin K . Petersen" , Greg Kroah-Hartman , "linux-mmc@vger.kernel.org" , "patches@lists.linux.dev" , =?iso-8859-1?Q?Christoph_B=F6hmwalder?= , "linux-crypto@vger.kernel.org" , Sakari Ailus , "linux-fsdevel@vger.kernel.org" , Andrew Morton , "linuxppc-dev@lists.ozlabs.org" Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" From: Theodore Ts'o > Sent: 17 November 2022 15:43 ... > The problem with "between", "ranged", "spanning" is that they don't > tell the reader whether we're dealing with an "open interval" or a > "closed interval". They are just different ways of saying that it's a > range between, say, 0 and 20. But it doesn't tell you whether it > includes 0 or 20 or not. >=20 > The only way I can see for making it ambiguous is either to use the > terminology "closed interval" or "inclusive". And "open" and "closed" > can have other meanings, so get_random_u32_inclusive() is going to be > less confusing than get_random_u32_closed(). It has to be said that removing the extra function and requiring the callers use 'base + get_random_below(high [+1] - base)' is likely to be the only way to succinctly make the code readable and understandable. Otherwise readers either have to look up another function to see what it does or waste variable brain cells on more trivia. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)