diff options
Diffstat (limited to 'src/rnd.c')
-rw-r--r-- | src/rnd.c | 38 |
1 files changed, 19 insertions, 19 deletions
@@ -99,23 +99,23 @@ double prne_rnd_gen_double (prne_rnd_engine_t *engine) { prne_rnd_engine_t *prne_mk_rnd_engine (void) { uint32_t seed = 0; - prne_rnd_engnie_alloc_result_t ret; - - getrandom(&seed, sizeof(uint32_t), 0); - - if (seed == 0) { - // fall back to seeding with what's available. - seed = - (uint32_t)(time(NULL) % 0xFFFFFFFF) ^ - (uint32_t)(getpid() % 0xFFFFFFFF) ^ - (uint32_t)(getppid() % 0xFFFFFFFF) ^ - (uint32_t)(clock() % 0xFFFFFFFF); - } - - ret = prne_alloc_rnd_engine(seed == 0 ? NULL : &seed); - if (ret.result != PRNE_RND_ENGINE_ALLOC_OK) { - return NULL; - } - - return ret.engine; + prne_rnd_engnie_alloc_result_t ret; + + getrandom(&seed, sizeof(uint32_t), 0); + + if (seed == 0) { + // fall back to seeding with what's available. + seed = + (uint32_t)(time(NULL) % 0xFFFFFFFF) ^ + (uint32_t)(getpid() % 0xFFFFFFFF) ^ + (uint32_t)(getppid() % 0xFFFFFFFF) ^ + (uint32_t)(clock() % 0xFFFFFFFF); + } + + ret = prne_alloc_rnd_engine(seed == 0 ? NULL : &seed); + if (ret.result != PRNE_RND_ENGINE_ALLOC_OK) { + return NULL; + } + + return ret.engine; } |