#else
rng = ::arg()["rng"];
rdev = ::arg()["entropy-source"];
- if (rng == "auto") { // NOLINT: I see no way to avoid repeating blocks reported bby clang-tidy
+ if (rng == "auto") { // NOLINT: I see no way to avoid repeating blocks reported by clang-tidy
#if defined(HAVE_GETRANDOM)
chosen_rng = RNG_GETRANDOM;
#elif defined(HAVE_ARC4RANDOM)
}
#if defined(HAVE_KISS_RNG)
if (chosen_rng == RNG_KISS) {
- unsigned int seed;
- urandom_fd = open(rdev.c_str(), O_RDONLY);
- if (urandom_fd == -1)
+ int fileDesc = open(rdev.c_str(), O_RDONLY);
+ if (fileDesc == -1) {
throw std::runtime_error("Cannot open " + rdev + ": " + stringerror());
+ }
+ unsigned int seed = 0;
if (read(urandom_fd, &seed, sizeof(seed)) < 0) {
- (void)close(urandom_fd);
+ (void)close(fileDesc);
throw std::runtime_error("Cannot read random device");
}
kiss_init(seed);
- (void)close(urandom_fd);
+ (void)close(fileDesc);
}
#endif
}
if (errno == EINTR) {
continue;
}
-
- (void)close(urandom_fd);
throw std::runtime_error("Cannot read random device");
}
if (static_cast<size_t>(got) != sizeof(num)) {
if (errno == EINTR) {
continue;
}
-
- (void)close(urandom_fd);
throw std::runtime_error("Cannot read random device");
}
if (static_cast<size_t>(got) != sizeof(num)) {