Do not use rand() to set a BranchList id

Use a simple counting instead, beecause Coverity complains that rand()
is not safe, and counting is siimpler anyway.
This commit is contained in:
Jean-Marc Lasgouttes 2024-09-13 11:07:05 +02:00
parent 9b3c28178c
commit 9f40eaee15
2 changed files with 6 additions and 2 deletions

View File

@ -32,6 +32,11 @@ docstring const & Branch::branch() const
return branch_; return branch_;
} }
static int list_id_generator = 0;
BranchList::BranchList()
: separator_(from_ascii("|")), id_(++list_id_generator) {}
void Branch::setBranch(docstring const & s) void Branch::setBranch(docstring const & s)
{ {

View File

@ -14,7 +14,6 @@
#include "support/docstring.h" #include "support/docstring.h"
#include <cstdlib> // rand()
#include <list> #include <list>
@ -104,7 +103,7 @@ public:
typedef List::const_iterator const_iterator; typedef List::const_iterator const_iterator;
/// ///
BranchList() : separator_(from_ascii("|")), id_(rand()) {} BranchList();
/// ///
docstring separator() const { return separator_; } docstring separator() const { return separator_; }