aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-05-19 09:34:20 +0100
committerfanquake <fanquake@gmail.com>2023-05-20 17:09:48 +0100
commitc2ba3f5b0c7d0eece7d16d1ffc125d8a6a9297af (patch)
tree775b0bdd1b90561f1f561fc94aec584137ca7ab1 /src/random.cpp
parentc13c97dbf846cf0e6a5581ac414ef96a215b0dc6 (diff)
downloadbitcoin-c2ba3f5b0c7d0eece7d16d1ffc125d8a6a9297af.tar.xz
random: add [[maybe_unused]] to GetDevURandom
Rather than multiple instances of (void)GetDevURandom to silence compiler warnings.
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/src/random.cpp b/src/random.cpp
index 144a5c5318..61f342269f 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -251,7 +251,7 @@ static void Strengthen(const unsigned char (&seed)[32], SteadyClock::duration du
/** Fallback: get 32 bytes of system entropy from /dev/urandom. The most
* compatible way to get cryptographic randomness on UNIX-ish platforms.
*/
-static void GetDevURandom(unsigned char *ent32)
+[[maybe_unused]] static void GetDevURandom(unsigned char *ent32)
{
int f = open("/dev/urandom", O_RDONLY);
if (f == -1) {
@@ -310,14 +310,10 @@ void GetOSRand(unsigned char *ent32)
The function call is always successful.
*/
arc4random_buf(ent32, NUM_OS_RANDOM_BYTES);
- // Silence a compiler warning about unused function.
- (void)GetDevURandom;
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure();
}
- // Silence a compiler warning about unused function.
- (void)GetDevURandom;
#elif defined(HAVE_SYSCTL_ARND)
/* FreeBSD, NetBSD and similar. It is possible for the call to return less
* bytes than requested, so need to read in a loop.
@@ -331,8 +327,6 @@ void GetOSRand(unsigned char *ent32)
}
have += len;
} while (have < NUM_OS_RANDOM_BYTES);
- // Silence a compiler warning about unused function.
- (void)GetDevURandom;
#else
/* Fall back to /dev/urandom if there is no specific method implemented to
* get system entropy for this OS.