summaryrefslogtreecommitdiff
path: root/Userland/Applications
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-09-01 11:37:05 -0400
committerAndreas Kling <kling@serenityos.org>2021-09-02 00:39:12 +0200
commit902d24136b31dffc151234c8afcd09e81fbe9a98 (patch)
treeab6b5e213f6726914d39906ca143fd0a5b6435a1 /Userland/Applications
parent02121336b494de0722c0a2ef56a3dde6df7928cb (diff)
downloadserenity-902d24136b31dffc151234c8afcd09e81fbe9a98.zip
Welcome: Replace rand()/srand() with AK::get_random_uniform()
Diffstat (limited to 'Userland/Applications')
-rw-r--r--Userland/Applications/Welcome/WelcomeWidget.cpp11
1 files changed, 3 insertions, 8 deletions
diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp
index 35052907b5..39442953bd 100644
--- a/Userland/Applications/Welcome/WelcomeWidget.cpp
+++ b/Userland/Applications/Welcome/WelcomeWidget.cpp
@@ -5,6 +5,7 @@
*/
#include "WelcomeWidget.h"
+#include <AK/Random.h>
#include <Applications/Welcome/WelcomeWindowGML.h>
#include <LibCore/File.h>
#include <LibCore/Process.h>
@@ -17,7 +18,6 @@
#include <LibMarkdown/Document.h>
#include <LibWeb/OutOfProcessWebView.h>
#include <serenity.h>
-#include <time.h>
WelcomeWidget::WelcomeWidget()
{
@@ -68,7 +68,6 @@ WelcomeWidget::WelcomeWidget()
open_and_parse_readme_file();
open_and_parse_tips_file();
- srand(time(nullptr));
set_random_tip();
}
@@ -116,12 +115,8 @@ void WelcomeWidget::set_random_tip()
if (m_tips.is_empty())
return;
- size_t n;
- do
- n = rand();
- while (n >= m_tips.size());
- m_initial_tip_index = n;
- m_tip_label->set_text(m_tips[n]);
+ m_initial_tip_index = get_random_uniform(m_tips.size());
+ m_tip_label->set_text(m_tips[m_initial_tip_index]);
}
void WelcomeWidget::paint_event(GUI::PaintEvent& event)