Message ID | 20200609160620.GA29668@Johns-MacBook-Pro.local |
---|---|
State | New |
Headers | show |
Series | random: range is not portably RAND_MAX [BZ #7003] | expand |
On other platforms, RAND_MAX (which is the range of rand(3)) may differ from 2^31-1 (which is the range of random(3)). --- On Tue, Jun 09, 2020 at 05:08:45PM +0100, John Marshall wrote: > The fix applied for BZ #7003 made a similar change to manual/math.texi > but this comment was neglected. I am not FSF copyright assigned, but I > imagine this change is trivial enough not to need it. First ping as per [1] for this triviality. I used interval notation similar to lrand48() etc, but happy to leave it as "between 0 and 2^31-1 inclusive" if that's preferable. Cheers, John [1] https://sourceware.org/glibc/wiki/Contribution%20checklist stdlib/stdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index f971df4247..fb06bb9ac1 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -397,7 +397,7 @@ extern long int a64l (const char *__s) `initstate' and `setstate' functions are those from BSD Unices. The `rand' and `srand' functions are required by the ANSI standard. We provide both interfaces to the same random number generator. */ -/* Return a random long integer between 0 and RAND_MAX inclusive. */ +/* Return a random long integer in [0,2^31). */ extern long int random (void) __THROW; /* Seed the random number generator with the given number. */
On other platforms, RAND_MAX (which is the range of rand(3)) may differ from 2^31-1 (which is the range of random(3)). --- Second ping as per [1] for this trivial comment fix that completes the fix for BZ #7003 [2] made in 2013. This version of the patch keeps the "between ... inclusive" wording; see the previous version if avoiding writing "2^31-1" is preferred. I am not FSF copyright assigned, but I believe this change is trivial enough not to need it. [1] https://sourceware.org/glibc/wiki/Contribution%20checklist [2] https://sourceware.org/bugzilla/show_bug.cgi?id=7003 stdlib/stdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index f971df4247..3aa27a9d25 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -397,7 +397,7 @@ extern long int a64l (const char *__s) `initstate' and `setstate' functions are those from BSD Unices. The `rand' and `srand' functions are required by the ANSI standard. We provide both interfaces to the same random number generator. */ -/* Return a random long integer between 0 and RAND_MAX inclusive. */ +/* Return a random long integer between 0 and 2^31-1 inclusive. */ extern long int random (void) __THROW; /* Seed the random number generator with the given number. */
On 6/26/20 8:29 AM, John Marshall wrote: > On other platforms, RAND_MAX (which is the range of rand(3)) > may differ from 2^31-1 (which is the range of random(3)). Agreed. This is the same change for bug 7003, but in the header. I've pushed your change. Thanks! Reviewed-by: Carlos O'Donell <carlos@redhat.com> > --- > Second ping as per [1] for this trivial comment fix that completes > the fix for BZ #7003 [2] made in 2013. This version of the patch > keeps the "between ... inclusive" wording; see the previous version > if avoiding writing "2^31-1" is preferred. > > I am not FSF copyright assigned, but I believe this change is trivial > enough not to need it. > > [1] https://sourceware.org/glibc/wiki/Contribution%20checklist > [2] https://sourceware.org/bugzilla/show_bug.cgi?id=7003 > > stdlib/stdlib.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h > index f971df4247..3aa27a9d25 100644 > --- a/stdlib/stdlib.h > +++ b/stdlib/stdlib.h > @@ -397,7 +397,7 @@ extern long int a64l (const char *__s) > `initstate' and `setstate' functions are those from BSD Unices. > The `rand' and `srand' functions are required by the ANSI standard. > We provide both interfaces to the same random number generator. */ > -/* Return a random long integer between 0 and RAND_MAX inclusive. */ > +/* Return a random long integer between 0 and 2^31-1 inclusive. */ > extern long int random (void) __THROW; > > /* Seed the random number generator with the given number. */ >
diff --git a/stdlib/stdlib.h b/stdlib/stdlib.h index f971df4247..fb06bb9ac1 100644 --- a/stdlib/stdlib.h +++ b/stdlib/stdlib.h @@ -397,7 +397,7 @@ extern long int a64l (const char *__s) `initstate' and `setstate' functions are those from BSD Unices. The `rand' and `srand' functions are required by the ANSI standard. We provide both interfaces to the same random number generator. */ -/* Return a random long integer between 0 and RAND_MAX inclusive. */ +/* Return a random long integer in [0,2^31). */ extern long int random (void) __THROW; /* Seed the random number generator with the given number. */