From c3cb44cd22a99a11c0d7e91c5c4b28684c091e38 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Fri, 13 Mar 2020 14:32:29 -0700 Subject: [PATCH] [cppcheck] don't use rand_r POSIX 2008 marks it as obsolete. Found with rand_rCalled Signed-off-by: Rosen Penev --- src/history.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/history.cpp b/src/history.cpp index ffebae168..9ef4e4887 100644 --- a/src/history.cpp +++ b/src/history.cpp @@ -398,7 +398,8 @@ void history_impl_t::save_unless_disabled() { if (countdown_to_vacuum < 0) { unsigned int seed = static_cast(time(nullptr)); // Generate a number in the range [0, kVacuumFrequency). - countdown_to_vacuum = rand_r(&seed) / (RAND_MAX / kVacuumFrequency + 1); + srand(seed); + countdown_to_vacuum = rand() / (RAND_MAX / kVacuumFrequency + 1); } // Determine if we're going to vacuum.