Merge #17563: lib: fix a compiler warning: unused GetDevURandom()

ca2e47437277ef6851a739f247b44e73a53f21a1 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 ca2e47437277ef6851a739f247b44e73a53f21a1 -- increased signal to noise in compiler diagnostics is good
  sipa:
    utACK ca2e47437277ef6851a739f247b44e73a53f21a1
  hebasto:
    re-ACK ca2e47437277ef6851a739f247b44e73a53f21a1, tested on macOS 10.15.6 + llvm clang 10.0.0

Tree-SHA512: 03c98f00dad5d9a3c5c9f68553d72ad5489ec02f18b9769108a22003ec7be7819a731b1eab6a9f64dafb5be0efddccf6980de7e3bb90cd20d4f4d72f74124675
This commit is contained in:
fanquake 2020-08-10 20:56:12 +08:00 committed by pasta
parent fb7b4bbdca
commit 3c79f6120f

View File

@ -245,6 +245,8 @@ void GetOSRand(unsigned char *ent32)
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure();
}
// Silence a compiler warning about unused function.
(void)GetDevURandom;
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
// We need a fallback for OSX < 10.12
if (&getentropy != nullptr) {
@ -254,6 +256,8 @@ void GetOSRand(unsigned char *ent32)
} else {
GetDevURandom(ent32);
}
// Silence a compiler warning about unused function.
(void)GetDevURandom;
#elif defined(HAVE_SYSCTL_ARND)
/* FreeBSD and similar. It is possible for the call to return less
* bytes than requested, so need to read in a loop.
@ -267,6 +271,8 @@ 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.