public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] - remove local random function, use lib/random.c random32()
@ 2007-02-19 19:25 Joe Perches
  0 siblings, 0 replies; only message in thread
From: Joe Perches @ 2007-02-19 19:25 UTC (permalink / raw)
  To: linux-xfs

reducing the number of random number functions

Signed-off-by: Joe Perches <joe@perches.com>

diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c
index 4363512..200b701 100644
--- a/fs/xfs/support/debug.c
+++ b/fs/xfs/support/debug.c
@@ -78,20 +78,3 @@ assfail(char *expr, char *file, int line)
 	printk("Assertion failed: %s, file: %s, line: %d\n", expr, file, line);
 	BUG();
 }
-
-#if ((defined(DEBUG) || defined(INDUCE_IO_ERRROR)) && !defined(NO_WANT_RANDOM))
-unsigned long random(void)
-{
-	static unsigned long	RandomValue = 1;
-	/* cycles pseudo-randomly through all values between 1 and 2^31 - 2 */
-	register long	rv = RandomValue;
-	register long	lo;
-	register long	hi;
-
-	hi = rv / 127773;
-	lo = rv % 127773;
-	rv = 16807 * lo - 2836 * hi;
-	if (rv <= 0) rv += 2147483647;
-	return RandomValue = rv;
-}
-#endif /* DEBUG || INDUCE_IO_ERRROR || !NO_WANT_RANDOM */
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h
index 4f54dca..2cdb4cd 100644
--- a/fs/xfs/support/debug.h
+++ b/fs/xfs/support/debug.h
@@ -40,7 +40,7 @@ extern void assfail(char *expr, char *f, int l);
 # define ASSERT(expr)	((void)0)
 #else
 # define ASSERT(expr)	ASSERT_ALWAYS(expr)
-extern unsigned long random(void);
+# include <linux/random.h>
 #endif
 
 #ifndef STATIC
diff --git a/fs/xfs/xfs_alloc.c b/fs/xfs/xfs_alloc.c
index e80dda3..8e9a40a 100644
--- a/fs/xfs/xfs_alloc.c
+++ b/fs/xfs/xfs_alloc.c
@@ -764,7 +764,7 @@ xfs_alloc_ag_vextent_near(
 	 */
 	int		dofirst;	/* set to do first algorithm */
 
-	dofirst = random() & 1;
+	dofirst = random32() & 1;
 #endif
 	/*
 	 * Get a cursor for the by-size btree.
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c
index b95681b..35df82d 100644
--- a/fs/xfs/xfs_error.c
+++ b/fs/xfs/xfs_error.c
@@ -80,7 +80,7 @@ xfs_error_test(int error_tag, int *fsidp, char *expression,
 	int i;
 	int64_t fsid;
 
-	if (random() % randfactor)
+	if (random32() % randfactor)
 		return 0;
 
 	memcpy(&fsid, fsidp, sizeof(xfs_fsid_t));

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2007-02-19 20:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-02-19 19:25 [PATCH] - remove local random function, use lib/random.c random32() Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox