Re: [PATCH mh/lockfile-retry] lockfile: replace random() by rand()
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 4, 2015, 15:57 UTC
- Message-ID
- <CAPc5daXsvYppq0=2EU=Ah=MMWtva4_Q8325h7g1phGiDx0RAgg@mail.gmail.com>
- In-Reply-To
- <557039AE.3020107@alum.mit.edu>
On Thu, Jun 4, 2015 at 4:42 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 5 quoted lines
> On 06/04/2015 10:40 AM, Johannes Sixt wrote: > We *certainly* don't require high-quality random numbers for this > application. Regarding portability, there is one definite point in favor > of rand() (it's available on Windows) vs. Junio's recollection that > random() might have portability advantages, presumably on other platforms.
I agree that anything is OK in this codepath. I just suspected that whichever one we pick, there would be somebody who says "oh, my system lacks it", and we will end up adding one of compat/{rand,random}.c to emulate.
And when I anticipated that future, my inclination was to prefer random(), not rand(), used in the code, not the other way around. Yes, both are in POSIX, but I was getting the impression that rand() is on its way out (and rand_r() is already marked as obsolete).
> Maybe the easiest thing would be to switch to using rand() and see if > the OS/2 and VMS users complain ;-)
We can certainly go that route and I am fine with that as the solution for today, as long as somebody will remember this discussion when that complaint comes, and make compat/random.c, and switch the in-code use to random(), instead of sticking to use of rand() in code.