[PATCH 2/2] Use urandom to get random seed
Andi Kleen
ak@linux.intel.com
Wed Sep 28 06:14:00 GMT 2011
On 9/27/2011 4:24 PM, Joseph S. Myers wrote:
> On Tue, 27 Sep 2011, Andi Kleen wrote:
>
>> if (!flag_random_seed)
>> {
>> + /* Try urandom first. Time of day is too likely to collide. */
>> +
>> + int fd = open("/dev/urandom", O_RDONLY);
>> + read(fd,&random_seed, sizeof(random_seed));
>> + close(fd);
> There appear to be no error checks and an unconditional fallthrough to the
> HAVE_GETTIMEOFDAY code. Also, missing spaces before open parentheses.
In case of any error the variable just stays 0, which is what is intended.
The gettimeofday code reads another variable and the decision between
the two is in
init_random_seed()
I'll fix the whitespace.
-Andi
More information about the Gcc-patches
mailing list