Skip to content

Commit ca2e474

Browse files
committed
Fix a compiler warning: unused GetDevURandom()
``` random.cpp:255:13: error: unused function 'GetDevURandom' [-Werror,-Wunused-function] ``` Clang 9.0.0, FreeBSD 12.1 Silence by planting a dummy reference to the `GetDevURandom` symbol in the places where we don't call the function.
1 parent 5bf45fe commit ca2e474

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/random.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,16 @@ void GetOSRand(unsigned char *ent32)
314314
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
315315
RandFailure();
316316
}
317+
// Silence a compiler warning about unused function.
318+
(void)GetDevURandom;
317319
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
318320
/* getentropy() is available on macOS 10.12 and later.
319321
*/
320322
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
321323
RandFailure();
322324
}
325+
// Silence a compiler warning about unused function.
326+
(void)GetDevURandom;
323327
#elif defined(HAVE_SYSCTL_ARND)
324328
/* FreeBSD, NetBSD and similar. It is possible for the call to return less
325329
* bytes than requested, so need to read in a loop.
@@ -333,6 +337,8 @@ void GetOSRand(unsigned char *ent32)
333337
}
334338
have += len;
335339
} while (have < NUM_OS_RANDOM_BYTES);
340+
// Silence a compiler warning about unused function.
341+
(void)GetDevURandom;
336342
#else
337343
/* Fall back to /dev/urandom if there is no specific method implemented to
338344
* get system entropy for this OS.

0 commit comments

Comments
 (0)