OSDN Git Service

replace arc4random() with the recommended arc4random_uniform() alternative
authorIvailo Monev <xakepa10@gmail.com>
Sun, 19 Sep 2021 00:33:50 +0000 (03:33 +0300)
committerIvailo Monev <xakepa10@gmail.com>
Sun, 19 Sep 2021 00:33:50 +0000 (03:33 +0300)
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
CMakeLists.txt
src/core/global/qglobal.cpp

index dab0ddd..73af287 100644 (file)
@@ -441,7 +441,7 @@ endif()
 katie_check_header("cxxabi.h")
 katie_check_function(posix_memalign "stdlib.h")
 katie_check_function(getprogname "stdlib.h")
-katie_check_function(arc4random "stdlib.h")
+katie_check_function(arc4random_uniform "stdlib.h")
 katie_check_function(get_current_dir_name "unistd.h")
 katie_check_function(prctl "sys/prctl.h")
 katie_check_function(feenableexcept "fenv.h")
index 4723c80..4dc43f4 100644 (file)
@@ -1413,8 +1413,8 @@ void qsrand(uint seed)
 */
 int qrand()
 {
-#ifdef QT_HAVE_ARC4RANDOM
-    return (::arc4random() % RAND_MAX);
+#ifdef QT_HAVE_ARC4RANDOM_UNIFORM
+    return ::arc4random_uniform(RAND_MAX);
 #else
     // Seed the PRNG once per thread with a combination of current time and its address
     thread_local time_t almostrandom = 0;