summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormestre <mestre@openbsd.org>2016-03-08 18:43:47 +0000
committermestre <mestre@openbsd.org>2016-03-08 18:43:47 +0000
commit7bda4eb305e71c5ccf2fdfa85af45d0884c3ae6e (patch)
treef1e7591e646bb3f81e80abd092f628f54f998a72
parentsync (diff)
downloadwireguard-openbsd-7bda4eb305e71c5ccf2fdfa85af45d0884c3ae6e.tar.xz
wireguard-openbsd-7bda4eb305e71c5ccf2fdfa85af45d0884c3ae6e.zip
- ranf() and franf() are prototyped on trek.h but ranf.c doesn't include it so
do it - Replace random() >> 5 by only random(): this was discussed a few months ago and naddy@ said at the time "Those games were originally written with the rand(3) function. The lower bits returned by rand(3) suffered from notoriously poor randomness, so this idiom developed where people would use the higher, more random bits." OK tb@ after his remarks
-rw-r--r--games/trek/ranf.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/games/trek/ranf.c b/games/trek/ranf.c
index bc4f530f45a..964c8c4f938 100644
--- a/games/trek/ranf.c
+++ b/games/trek/ranf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ranf.c,v 1.7 2016/01/07 14:37:51 mestre Exp $ */
+/* $OpenBSD: ranf.c,v 1.8 2016/03/08 18:43:47 mestre Exp $ */
/* $NetBSD: ranf.c,v 1.3 1995/04/22 10:59:21 cgd Exp $ */
/*
@@ -32,6 +32,8 @@
#include <stdlib.h>
+#include "trek.h"
+
int
ranf(int max)
{
@@ -39,7 +41,7 @@ ranf(int max)
if (max <= 0)
return (0);
- t = random() >> 5;
+ t = random();
return (t % max);
}