xfs
[Top] [All Lists]

[PATCH] - remove local random function, use lib/random.c random32()

To: linux-xfs@xxxxxxxxxxx
Subject: [PATCH] - remove local random function, use lib/random.c random32()
From: Joe Perches <joe@xxxxxxxxxxx>
Date: Mon, 19 Feb 2007 11:25:37 -0800
Sender: xfs-bounce@xxxxxxxxxxx
reducing the number of random number functions

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>

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));



<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] - remove local random function, use lib/random.c random32(), Joe Perches <=