some pa_bool_t'ization

This commit is contained in:
Lennart Poettering 2008-08-03 17:00:52 +02:00
parent 98fbd24d62
commit f417bb42cf

View file

@ -37,7 +37,7 @@
#include "random.h" #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 }; static const char * const devices[] = { "/dev/urandom", "/dev/random", NULL };
@ -89,9 +89,11 @@ void pa_random_seed(void) {
unsigned int seed; unsigned int seed;
if (random_proper(&seed, sizeof(unsigned int)) < 0) { 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."); 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); seed = (unsigned int) time(NULL);
} }
@ -109,9 +111,10 @@ void pa_random(void *ret_data, size_t length) {
if (random_proper(ret_data, length) >= 0) if (random_proper(ret_data, length) >= 0)
return; return;
if (!has_whined) if (!has_whined) {
pa_log_warn("Failed to get proper entropy. Falling back to unsecure pseudo RNG."); 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--) for (p = ret_data, l = length; l > 0; p++, l--)
*p = (uint8_t) rand(); *p = (uint8_t) rand();