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

 



From: Tyson Smith <tyson.w.smith@xxxxxxxxx>

The body of get_len() was the same as rand32() so applying it to a value
from rand32() didn't offer much value. A switch case could be
added that generates other length like values as well. This could include
2^n +/- ~2, page_size +/- 1, MAX_INT... etc.
---
 random-length.c | 40 +---------------------------------------
 1 file changed, 1 insertion(+), 39 deletions(-)

diff --git a/random-length.c b/random-length.c
index a1a72e3..1ef3dd2 100644
--- a/random-length.c
+++ b/random-length.c
@@ -1,45 +1,7 @@
-#include <stdlib.h>
-
-#include "arch.h"	// page_size
 #include "sanitise.h"
 #include "random.h"
 
 unsigned long get_len(void)
 {
-	int i = 0;
-
-	i = rand32();
-
-	/* short circuit if 0 */
-	if (i == 0)
-		return 0;
-
-	switch (rand() % 6) {
-
-	case 0:	i &= 0xff;
-		break;
-	case 1: i &= page_size - 1;
-		break;
-	case 2:	i &= 0xffff;
-		break;
-	case 3:	i &= 0xffffff;
-		break;
-	case 4:	i &= 0xffffffff;
-		break;
-	case 5:
-		// Pass through
-		break;
-	}
-
-	/* again, short circuit if 0 */
-	if (i == 0)
-		return 0;
-
-	/* we might get lucky if something is counting ints/longs etc. */
-	if (ONE_IN(4)) {
-		int _div = 1 << RAND_RANGE(1, 4);	/* 2,4,8 or 16 */
-		i /= _div;
-	}
-
-	return i;
+	return rand32();
 }
-- 
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