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

ca2e474372 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 ca2e474372 -- increased signal to noise in compiler diagnostics is good
  sipa:
    utACK ca2e474372
  hebasto:
    re-ACK ca2e474372, 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

View File

@@ -315,12 +315,16 @@ void GetOSRand(unsigned char *ent32)
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure(); RandFailure();
} }
// Silence a compiler warning about unused function.
(void)GetDevURandom;
#elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX) #elif defined(HAVE_GETENTROPY_RAND) && defined(MAC_OSX)
/* getentropy() is available on macOS 10.12 and later. /* getentropy() is available on macOS 10.12 and later.
*/ */
if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) { if (getentropy(ent32, NUM_OS_RANDOM_BYTES) != 0) {
RandFailure(); RandFailure();
} }
// Silence a compiler warning about unused function.
(void)GetDevURandom;
#elif defined(HAVE_SYSCTL_ARND) #elif defined(HAVE_SYSCTL_ARND)
/* FreeBSD, NetBSD and similar. It is possible for the call to return less /* FreeBSD, NetBSD and similar. It is possible for the call to return less
* bytes than requested, so need to read in a loop. * bytes than requested, so need to read in a loop.
@@ -334,6 +338,8 @@ void GetOSRand(unsigned char *ent32)
} }
have += len; have += len;
} while (have < NUM_OS_RANDOM_BYTES); } while (have < NUM_OS_RANDOM_BYTES);
// Silence a compiler warning about unused function.
(void)GetDevURandom;
#else #else
/* Fall back to /dev/urandom if there is no specific method implemented to /* Fall back to /dev/urandom if there is no specific method implemented to
* get system entropy for this OS. * get system entropy for this OS.