summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Strode <rstrode@redhat.com>2023-12-03 19:06:47 -0500
committerRay Strode <rstrode@redhat.com>2023-12-04 07:49:31 -0500
commit75d371edeff1ec0f47218a7d5e2f0696950a47e7 (patch)
tree3a9201ff707bd8f1f49113456f72b6a9549edb57
parent0628f3b6e27e4827505cc53385e4e26f0452e54f (diff)
script: Use new ply_get_random_number function
-rw-r--r--src/plugins/splash/script/script-lib-math.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/plugins/splash/script/script-lib-math.c b/src/plugins/splash/script/script-lib-math.c
index be8eec97..292aa6d4 100644
--- a/src/plugins/splash/script/script-lib-math.c
+++ b/src/plugins/splash/script/script-lib-math.c
@@ -29,6 +29,7 @@
#include "script-object.h"
#include "script-lib-math.h"
#include <assert.h>
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -60,7 +61,7 @@ static script_return_t script_lib_math_double_from_double_double_function (scrip
static script_return_t script_lib_math_random (script_state_t *state,
void *user_data)
{
- double reply_double = random () / ((double) RAND_MAX + 1);
+ double reply_double = ply_get_random_number (0, LONG_MAX) / ((double) LONG_MAX);
return script_return_obj (script_obj_new_number (reply_double));
}
@@ -69,7 +70,6 @@ script_lib_math_data_t *script_lib_math_setup (script_state_t *state)
{
script_lib_math_data_t *data = malloc (sizeof(script_lib_math_data_t));
- srand ((int) ply_get_timestamp ());
script_obj_t *math_hash = script_obj_hash_get_element (state->global, "Math");