[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tyson Smith <tysmith@xxxxxxxxxxxx>

This function basically generates 256 different values. These values do not
seem to have much significance and unless it has triggered results in the
past it should likely be removed.
---
 random.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/random.c b/random.c
index aab85b0..bf32648 100644
--- a/random.c
+++ b/random.c
@@ -93,16 +93,15 @@ static unsigned long randbits(int limit)
 /*
  * Pick 1 random byte, and repeat it through a long.
  */
-static unsigned long rept8(unsigned int num)
+static unsigned long rept_byte(void)
 {
-	unsigned long r = 0UL;
-	unsigned int i;
-	unsigned char c;
-
-	c = RAND_BYTE();
-	for (i = rand() % (num - 1) ; i > 0; --i)
-		r = (r << 8) | c;
+	unsigned long r = RAND_BYTE();
 
+	r = (r << 8) | r;
+	r = (r << 16) | r;
+#if __WORDSIZE == 64
+	r = (r << 32) | r;
+#endif
 	return r;
 }
 
@@ -121,7 +120,7 @@ static unsigned int __rand32(void)
 		break;
 	case 2: r = RAND_32();
 		break;
-	case 3:	r = rept8(4);
+	case 3:	r = rept_byte();
 		break;
 	case 4:	return get_interesting_value();
 	}
@@ -203,7 +202,7 @@ u64 rand64(void)
 			break;
 		case 2:	r = RAND_64();
 			break;
-		case 3:	r = rept8(8);
+		case 3:	r = rept_byte();
 			break;
 		/* Sometimes pick a not-so-random number. */
 		case 4:	return get_interesting_value();
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe trinity" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux