Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 2 Dec 2017 00:07:20 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326445 - head/stand/libsa
Message-ID:  <201712020007.vB207KTY033860@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Dec  2 00:07:19 2017
New Revision: 326445
URL: https://svnweb.freebsd.org/changeset/base/326445

Log:
  Fix random() and srandom() prototypes to match the standard.
  
  These prototypes were needlessly different from the standard. Fix them
  to be the same, and fix the surrounding code after the changes.
  
  Sponsored by: Netflix

Modified:
  head/stand/libsa/libstand.3
  head/stand/libsa/random.c
  head/stand/libsa/stand.h

Modified: head/stand/libsa/libstand.3
==============================================================================
--- head/stand/libsa/libstand.3	Sat Dec  2 00:07:14 2017	(r326444)
+++ head/stand/libsa/libstand.3	Sat Dec  2 00:07:19 2017	(r326445)
@@ -169,10 +169,10 @@ may be used to prevent a variable being unset.
 .Xc
 .It Xo
 .Ft void
-.Fn srandom "unsigned long seed"
+.Fn srandom "unsigned int seed"
 .Xc
 .It Xo
-.Ft "unsigned long"
+.Ft "long"
 .Fn random void
 .Xc
 .It Xo

Modified: head/stand/libsa/random.c
==============================================================================
--- head/stand/libsa/random.c	Sat Dec  2 00:07:14 2017	(r326444)
+++ head/stand/libsa/random.c	Sat Dec  2 00:07:19 2017	(r326445)
@@ -34,12 +34,12 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/types.h>
 
-static u_long randseed = 1;
+static long randseed = 1;
 
 void
-srandom(seed)
-	u_long seed;
+srandom(unsigned int seed)
 {
+
 	randseed = seed;
 }
 
@@ -48,8 +48,8 @@ srandom(seed)
  * and whatever else we might use it for.  The result is uniform on
  * [0, 2^31 - 1].
  */
-u_long
-random()
+long
+random(void)
 {
 	long x, hi, lo, t;
 

Modified: head/stand/libsa/stand.h
==============================================================================
--- head/stand/libsa/stand.h	Sat Dec  2 00:07:14 2017	(r326444)
+++ head/stand/libsa/stand.h	Sat Dec  2 00:07:19 2017	(r326445)
@@ -281,7 +281,7 @@ extern ssize_t	read(int, void *, size_t);
 extern ssize_t	write(int, void *, size_t);
 extern struct	dirent *readdirfd(int);
 
-extern void	srandom(u_long seed);
+extern void	srandom(unsigned int);
 extern u_long	random(void);
     
 /* imports from stdlib, locally modified */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201712020007.vB207KTY033860>