[cppcheck] don't use rand_r

POSIX 2008 marks it as obsolete.

Found with rand_rCalled

Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
Rosen Penev 2020-03-13 14:32:29 -07:00 committed by ridiculousfish
parent fdb2837bc7
commit c3cb44cd22

View file

@ -398,7 +398,8 @@ void history_impl_t::save_unless_disabled() {
if (countdown_to_vacuum < 0) {
unsigned int seed = static_cast<unsigned int>(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.