]> git.ipfire.org Git - thirdparty/plymouth.git/commitdiff
script: Use new ply_get_random_number function
authorRay Strode <rstrode@redhat.com>
Mon, 4 Dec 2023 00:06:47 +0000 (19:06 -0500)
committerRay Strode <rstrode@redhat.com>
Mon, 4 Dec 2023 12:49:31 +0000 (07:49 -0500)
src/plugins/splash/script/script-lib-math.c

index be8eec97bff2a5fd45f535e46b0571d2964b2bbb..292aa6d41bf33918424667e0c5e2c0cca256a995 100644 (file)
@@ -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");