Date: Sat, 21 May 2016 17:40:16 -0500 From: Pedro Giffuni <pfg@FreeBSD.org> To: cem@FreeBSD.org Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r300377 - head/sys/compat/ndis Message-ID: <262938a6-50bd-b6f4-24c9-895b837a368e@FreeBSD.org> In-Reply-To: <CAG6CVpV_3%2B%2BWqg2X23=RM942zaDkyL6fxH2YN0TXUqpPjneCOw@mail.gmail.com> References: <201605211752.u4LHqiHQ031457@repo.freebsd.org> <CAG6CVpXjU3tHdar7d=xyr%2BTmffg0NrQu3q7SD=b6%2BjF=yvVr-Q@mail.gmail.com> <a88c14ea-ee78-54de-6142-08a561a49d98@FreeBSD.org> <CAG6CVpV_3%2B%2BWqg2X23=RM942zaDkyL6fxH2YN0TXUqpPjneCOw@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 05/21/16 16:55, Conrad Meyer wrote: > On Sat, May 21, 2016 at 1:40 PM, Pedro Giffuni <pfg@freebsd.org> wrote: >> >> >> On 05/21/16 14:05, Conrad Meyer wrote: >>> Won't this still return a negative integer in many cases? >>> >>> random(9) returns u_long, whereas this rand() routine returns 'int'. >>> >>> Even on architectures where long is the same size as ordinary >>> integers, the range of possible results of the 'random() / 2 + 1' >>> expression, before implicit cast to signed, is [1, 2^31] (inclusive). >> >> >> According to: >> sys/libkern/random.c >> >> The result is uniform on [0, 2^31 - 1]. > > Ah, I missed that. Sorry! In that case, I'm not sure why this is > needed — the result fits in a non-negative 2's complement signed > integer. > Actually, I had missed it too. And I also had no idea we were working around the zero singularity. I will revert the change and will do an adjustment for the case where we use 0 as a seed (which in MS should be equivalent to 1). Pedro.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?262938a6-50bd-b6f4-24c9-895b837a368e>