From e90e3e684ffa7b25f0dfb5b45e70bb0c358261fb Mon Sep 17 00:00:00 2001 From: fanquake Date: Mon, 16 Mar 2020 17:20:27 +0800 Subject: build: fix sysctl() detection on macOS sysctl() on *BSD takes a "const int *name", whereas sysctl() on macOS it takes an "int *name". So our configure check and sysctl() detection on macOS currently fails: ```bash /usr/include/sys/sysctl.h:759:9: note: candidate function not viable: no known conversion from 'const int [2]' to 'int *' for 1st argument int sysctl(int *, u_int, void *, size_t *, void *, size_t); ``` This change removes the name argument from the sysctl() detection check, meaning we will detect correctly on macOS and *BSD. For consistency we also switch to using the more generic, non-const version of the name parameter in the rest of our usage. --- src/random.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/random.cpp') diff --git a/src/random.cpp b/src/random.cpp index f7f3dd9de..2a27e6ba0 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -321,10 +321,10 @@ void GetOSRand(unsigned char *ent32) RandFailure(); } #elif defined(HAVE_SYSCTL_ARND) - /* FreeBSD 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. */ - static const int name[2] = {CTL_KERN, KERN_ARND}; + static int name[2] = {CTL_KERN, KERN_ARND}; int have = 0; do { size_t len = NUM_OS_RANDOM_BYTES - have; -- cgit v1.2.3