diff --git a/configure.ac b/configure.ac index 758d31192b1..23a6417a1ac 100644 --- a/configure.ac +++ b/configure.ac @@ -935,11 +935,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include AC_MSG_CHECKING(for sysctl) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include ]], - [[ static const int name[2] = {CTL_KERN, KERN_VERSION}; - #ifdef __linux__ + [[ #ifdef __linux__ #error "Don't use sysctl on Linux, it's deprecated even when it works" #endif - sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])], + sysctl(nullptr, 2, nullptr, nullptr, nullptr, 0); ]])], [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL, 1,[Define this symbol if the BSD sysctl() is available]) ], [ AC_MSG_RESULT(no)] ) @@ -947,7 +946,10 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include AC_MSG_CHECKING(for sysctl KERN_ARND) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include #include ]], - [[ static const int name[2] = {CTL_KERN, KERN_ARND}; + [[ #ifdef __linux__ + #error "Don't use sysctl on Linux, it's deprecated even when it works" + #endif + static int name[2] = {CTL_KERN, KERN_ARND}; sysctl(name, 2, nullptr, nullptr, nullptr, 0); ]])], [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYSCTL_ARND, 1,[Define this symbol if the BSD sysctl(KERN_ARND) is available]) ], [ AC_MSG_RESULT(no)] diff --git a/src/random.cpp b/src/random.cpp index f7f3dd9de38..2a27e6ba0d3 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;