From fc2d67bac1084a35835c57c1655445529f37c8d8 Mon Sep 17 00:00:00 2001 From: Yamagi Burmeister Date: Sat, 2 Jun 2012 12:11:14 +0200 Subject: [PATCH] Ensure that pseudo random numbers are always >0 --- src/common/shared/rand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/common/shared/rand.c b/src/common/shared/rand.c index c2b97b2c..0a09cf84 100644 --- a/src/common/shared/rand.c +++ b/src/common/shared/rand.c @@ -40,12 +40,17 @@ B64MWC(void) /* * Generate a pseudorandom - * signed integer. + * integer >0. */ int randk(void) { - return (int)KISS; + int r; + + r = (int)KISS; + r = (r < 0) ? (r * -1) : r; + + return r; } /*