Skip to content

Commit c2ba3f5

Browse files
committed
random: add [[maybe_unused]] to GetDevURandom
Rather than multiple instances of (void)GetDevURandom to silence compiler warnings.
1 parent c13c97d commit c2ba3f5

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

src/random.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ static void Strengthen(const unsigned char (&seed)[32], SteadyClock::duration du
251251
/** Fallback: get 32 bytes of system entropy from /dev/urandom. The most
252252
* compatible way to get cryptographic randomness on UNIX-ish platforms.
253253
*/
254-
static void GetDevURandom(unsigned char *ent32)
254+
[[maybe_unused]] static void GetDevURandom(unsigned char *ent32)
255255
{
256256
int f = open("/dev/urandom", O_RDONLY);
257257
if (f == -1) {
@@ -310,14 +310,10 @@ void GetOSRand(unsigned char *ent32)
310310
The function call is always successful.
311311
*/
312312
arc4random_buf(ent32, NUM_OS_RANDOM_BYTES);
313-
// Silence a compiler warning about unused function.
314-
(void)GetDevURandom;
315313
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
316314
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
317315
RandFailure();
318316
}
319-
// Silence a compiler warning about unused function.
320-
(void)GetDevURandom;
321317
#elif defined(HAVE_SYSCTL_ARND)
322318
/* FreeBSD, NetBSD and similar. It is possible for the call to return less
323319
* bytes than requested, so need to read in a loop.
@@ -331,8 +327,6 @@ void GetOSRand(unsigned char *ent32)
331327
}
332328
have += len;
333329
} while (have < NUM_OS_RANDOM_BYTES);
334-
// Silence a compiler warning about unused function.
335-
(void)GetDevURandom;
336330
#else
337331
/* Fall back to /dev/urandom if there is no specific method implemented to
338332
* get system entropy for this OS.

0 commit comments

Comments
 (0)