mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-09 09:07:52 +01:00
fix: the bugs and vulnerabilities SonarCloud reports on PR #216
This commit is contained in:
@@ -145,15 +145,15 @@ bool ClearFlag(int &Flag, int const Value)
|
||||
|
||||
namespace
|
||||
{
|
||||
thread_local std::mt19937 *t_random_engine{nullptr};
|
||||
thread_local std::mt19937 *t_random_engine{nullptr}; // NOSONAR: randomness of the simulation, not of anything security-relevant
|
||||
|
||||
std::mt19937 &random_engine()
|
||||
std::mt19937 &random_engine() // NOSONAR: randomness of the simulation, not of anything security-relevant
|
||||
{
|
||||
return t_random_engine != nullptr ? *t_random_engine : Global.random_engine;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void set_thread_random_engine(std::mt19937 *Engine)
|
||||
void set_thread_random_engine(std::mt19937 *Engine) // NOSONAR: randomness of the simulation, not of anything security-relevant
|
||||
{
|
||||
t_random_engine = Engine;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ double Random(double a, double b);
|
||||
int Random(int min, int max);
|
||||
// the engine Random() draws from in the calling thread, in place of Global.random_engine, or none for that one again. the threads
|
||||
// of worker_pool have engines of their own: the one of the simulation can't be shared between threads
|
||||
void set_thread_random_engine(std::mt19937 *Engine);
|
||||
void set_thread_random_engine(std::mt19937 *Engine); // NOSONAR: randomness of the simulation, not of anything security-relevant
|
||||
|
||||
/// @author lxvia
|
||||
/// @brief Returns a random seed from the system's entropy source, if available. Otherwise, falls back to a clock-based seed.
|
||||
|
||||
@@ -112,7 +112,7 @@ void worker_pool::work(std::function<void(std::size_t)> const &Work, std::size_t
|
||||
void worker_pool::worker(thread_data &Data)
|
||||
{
|
||||
// draws of Random() in this thread go to an engine of its own: the one of the simulation can't be shared between threads
|
||||
std::mt19937 randomengine(static_cast<std::mt19937::result_type>(true_random_seed()));
|
||||
std::mt19937 randomengine(static_cast<std::mt19937::result_type>(true_random_seed())); // NOSONAR: randomness of the simulation, not of anything security-relevant
|
||||
set_thread_random_engine(&randomengine);
|
||||
|
||||
while (true)
|
||||
|
||||
Reference in New Issue
Block a user