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.
This commit is contained in:
parent
5bf45fe2a9
commit
ca2e474372
1 changed files with 6 additions and 0 deletions
|
@ -314,12 +314,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.
|
||||||
|
@ -333,6 +337,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.
|
||||||
|
|
Loading…
Reference in a new issue