[PATCH] testbot: Simplify and speed up GenerateRandomString().

Francois Gouget fgouget at codeweavers.com
Tue Feb 4 08:52:07 CST 2020


Perl's rand() function can return random values greater than 2^16
nowadays.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/WineTestBot/Utils.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm
index e8ba5162dc..27b222fd21 100644
--- a/testbot/lib/WineTestBot/Utils.pm
+++ b/testbot/lib/WineTestBot/Utils.pm
@@ -201,8 +201,8 @@ sub GenerateRandomString($)
   my $RandomString = "";
   while (length($RandomString) < $Len)
   {
-    my $Part = "0000" . sprintf("%lx", int(rand(2 ** 16)));
-    $RandomString .= substr($Part, -4);
+    $RandomString .= sprintf("%08x", int(rand(2 ** 32)));
+
   }
 
   return substr($RandomString, 0, $Len);
-- 
2.20.1




More information about the wine-devel mailing list