Skip to content

Commit 04a0676

Browse files
committed
Merge #17563: lib: fix a compiler warning: unused GetDevURandom()
ca2e474 Fix a compiler warning: unused GetDevURandom() (Vasil Dimov) Pull request description: ~~Only define GetDevURandom() if it is going to be used.~~ Silence by planting a dummy reference to the `GetDevURandom` symbol in the places where we don't call the function. ACKs for top commit: practicalswift: ACK ca2e474 -- increased signal to noise in compiler diagnostics is good sipa: utACK ca2e474 hebasto: re-ACK ca2e474, tested on macOS 10.15.6 + llvm clang 10.0.0 Tree-SHA512: 03c98f00dad5d9a3c5c9f68553d72ad5489ec02f18b9769108a22003ec7be7819a731b1eab6a9f64dafb5be0efddccf6980de7e3bb90cd20d4f4d72f74124675
2 parents f306384 + ca2e474 commit 04a0676

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
@@ -315,12 +315,16 @@ void GetOSRand(unsigned char *ent32)
315315
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
316316
RandFailure();
317317
}
318+
// Silence a compiler warning about unused function.
319+
(void)GetDevURandom;
318320
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
319321
/* getentropy() is available on macOS 10.12 and later.
320322
*/
321323
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
322324
RandFailure();
323325
}
326+
// Silence a compiler warning about unused function.
327+
(void)GetDevURandom;
324328
#elif defined(HAVE_SYSCTL_ARND)
325329
/* FreeBSD, NetBSD and similar. It is possible for the call to return less
326330
* bytes than requested, so need to read in a loop.
@@ -334,6 +338,8 @@ void GetOSRand(unsigned char *ent32)
334338
}
335339
have += len;
336340
} while (have < NUM_OS_RANDOM_BYTES);
341+
// Silence a compiler warning about unused function.
342+
(void)GetDevURandom;
337343
#else
338344
/* Fall back to /dev/urandom if there is no specific method implemented to
339345
* get system entropy for this OS.

0 commit comments

Comments
 (0)