kern/162347: [patch] remove the extra variable in /sys/libkern/random.c

Ivan Klymenko fidaj at ukr.net
Mon Nov 7 05:50:12 UTC 2011


>Number:         162347
>Category:       kern
>Synopsis:       [patch] remove the extra variable in /sys/libkern/random.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Nov 07 05:50:12 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Ivan Klymenko
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
individual
>Environment:
FreeBSD nonamehost 9.9-CURRENT FreeBSD 9.9-CURRENT #0 r227075M: Sat Nov  5 16:13:18 EET 2011     ivan at nonamehost:/usr/obj/usr/src/sys/mk9  amd64
>Description:
remove the extra variable.
variable "x" is not needed.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- ./sys/libkern/random.c.orig	2011-11-05 15:36:23.000000000 +0200
+++ ./sys/libkern/random.c	2011-11-05 15:40:18.000000000 +0200
@@ -57,19 +57,19 @@
 u_long
 random()
 {
-	register long x, hi, lo, t;
+	register long hi, lo, t;
 
 	/*
-	 * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
+	 * Compute randseed[n + 1] = (7^5 * randseed[n]) mod (2^31 - 1).
 	 * From "Random number generators: good ones are hard to find",
 	 * Park and Miller, Communications of the ACM, vol. 31, no. 10,
 	 * October 1988, p. 1195.
 	 */
 	/* Can't be initialized with 0, so use another value. */
-	if ((x = randseed) == 0)
-		x = 123459876;
-	hi = x / 127773;
-	lo = x % 127773;
+	if (randseed == 0)
+		randseed = 123459876;
+	hi = randseed / 127773;
+	lo = randseed % 127773;
 	t = 16807 * lo - 2836 * hi;
 	if (t < 0)
 		t += 0x7fffffff;


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list