#include "random.h"
-static int has_whined = 0;
+static pa_bool_t has_whined = TRUE;
static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
unsigned int seed;
if (random_proper(&seed, sizeof(unsigned int)) < 0) {
- if (!has_whined)
+
+ if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to seeding with current time.");
- has_whined = 1;
+ has_whined = TRUE;
+ }
seed = (unsigned int) time(NULL);
}
if (random_proper(ret_data, length) >= 0)
return;
- if (!has_whined)
+ if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG.");
- has_whined = 1;
+ has_whined = TRUE;
+ }
for (p = ret_data, l = length; l > 0; p++, l--)
*p = (uint8_t) rand();