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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02AFBC4332F for ; Thu, 17 Nov 2022 22:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234851AbiKQWP7 convert rfc822-to-8bit (ORCPT ); Thu, 17 Nov 2022 17:15:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240496AbiKQWPr (ORCPT ); Thu, 17 Nov 2022 17:15:47 -0500 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.86.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3075E7AF6A for ; Thu, 17 Nov 2022 14:15:41 -0800 (PST) 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 CC: "Jason A. Donenfeld" , Kees Cook , "linux-kernel@vger.kernel.org" , "patches@lists.linux.dev" , Greg Kroah-Hartman , Jakub Kicinski , Russell King , Catalin Marinas , "Thomas Bogendoerfer" , Heiko Carstens , Herbert Xu , =?iso-8859-1?Q?Christoph_B=F6hmwalder?= , Jani Nikula , Jason Gunthorpe , Sakari Ailus , "Martin K . Petersen" , Andreas Dilger , Jaegeuk Kim , Richard Weinberger , "Darrick J . Wong" , SeongJae Park , "Thomas Gleixner" , Andrew Morton , Michael Ellerman , Helge Deller , "netdev@vger.kernel.org" , "linux-crypto@vger.kernel.org" , "linux-block@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-media@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "loongarch@lists.linux.dev" , "linux-mips@vger.kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "linux-mmc@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "ydroneaud@opteya.com" 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: 8BIT Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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. > > 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. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)