[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5b2afac148e24181a206e540768e465b@AcuMS.aculab.com>
Date: Thu, 17 Nov 2022 22:15:36 +0000
From: David Laight <David.Laight@...LAB.COM>
To: 'Theodore Ts'o' <tytso@....edu>, Kees Cook <kees@...nel.org>
CC: "Jason A. Donenfeld" <Jason@...c4.com>,
Kees Cook <keescook@...omium.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"patches@...ts.linux.dev" <patches@...ts.linux.dev>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jakub Kicinski <kuba@...nel.org>,
Russell King <linux@...linux.org.uk>,
Catalin Marinas <catalin.marinas@....com>,
"Thomas Bogendoerfer" <tsbogend@...ha.franken.de>,
Heiko Carstens <hca@...ux.ibm.com>,
Herbert Xu <herbert@...dor.apana.org.au>,
Christoph Böhmwalder
<christoph.boehmwalder@...bit.com>,
Jani Nikula <jani.nikula@...ux.intel.com>,
Jason Gunthorpe <jgg@...dia.com>,
Sakari Ailus <sakari.ailus@...ux.intel.com>,
"Martin K . Petersen" <martin.petersen@...cle.com>,
Andreas Dilger <adilger.kernel@...ger.ca>,
Jaegeuk Kim <jaegeuk@...nel.org>,
Richard Weinberger <richard@....at>,
"Darrick J . Wong" <djwong@...nel.org>,
SeongJae Park <sj@...nel.org>,
"Thomas Gleixner" <tglx@...utronix.de>,
Andrew Morton <akpm@...ux-foundation.org>,
Michael Ellerman <mpe@...erman.id.au>,
Helge Deller <deller@....de>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
"linux-block@...r.kernel.org" <linux-block@...r.kernel.org>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
"linux-media@...r.kernel.org" <linux-media@...r.kernel.org>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"loongarch@...ts.linux.dev" <loongarch@...ts.linux.dev>,
"linux-mips@...r.kernel.org" <linux-mips@...r.kernel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"linux-mmc@...r.kernel.org" <linux-mmc@...r.kernel.org>,
"linux-parisc@...r.kernel.org" <linux-parisc@...r.kernel.org>,
"ydroneaud@...eya.com" <ydroneaud@...eya.com>
Subject: RE: [PATCH v2 3/3] treewide: use get_random_u32_between() when
possible
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)
Powered by blists - more mailing lists