trinity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tyson.w.smith@gmail.com
To: davej@codemonkey.org.uk
Cc: trinity@vger.kernel.org, Tyson Smith <tysmith@motorola.com>
Subject: [PATCH 03/12] Remove rand8x8()
Date: Fri,  6 Mar 2015 14:29:59 -0800	[thread overview]
Message-ID: <1425680999-28404-1-git-send-email-tyson.w.smith@gmail.com> (raw)

From: Tyson Smith <tysmith@motorola.com>

Removed rand8x8() function since it is essentially the same as a call
to RAND_32 or RAND_64.
---
 random.c | 30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/random.c b/random.c
index f425ed5..adee25e 100644
--- a/random.c
+++ b/random.c
@@ -90,20 +90,6 @@ static unsigned long randbits(int limit)
 }
 
 /*
- * Pick 8 random bytes, and concatenate them into a long.
- */
-static unsigned long rand8x8(void)
-{
-	unsigned long r = 0UL;
-	unsigned int i;
-
-	for (i = rand_range(1, 7); i > 0; --i)
-		r = (r << 8) | rand() % 256;
-
-	return r;
-}
-
-/*
  * Pick 1 random byte, and repeat it through a long.
  */
 static unsigned long rept8(unsigned int num)
@@ -127,18 +113,16 @@ static unsigned int __rand32(void)
 {
 	unsigned long r = 0;
 
-	switch (rand() % 6) {
+	switch (rand() % 5) {
 	case 0: r = rand_single_bit(32);
 		break;
 	case 1:	r = randbits(32);
 		break;
 	case 2: r = RAND_32();
 		break;
-	case 3:	r = rand8x8();
-		break;
-	case 4:	r = rept8(4);
+	case 3:	r = rept8(4);
 		break;
-	case 5:	return get_interesting_value();
+	case 4:	return get_interesting_value();
 	}
 
 	return r;
@@ -211,19 +195,17 @@ u64 rand64(void)
 
 	} else {
 		/* 33:64-bit ranges. */
-		switch (rand() % 6) {
+		switch (rand() % 5) {
 		case 0:	r = rand_single_bit(64);
 			break;
 		case 1:	r = randbits(64);
 			break;
 		case 2:	r = RAND_64();
 			break;
-		case 3:	r = rand8x8();
-			break;
-		case 4:	r = rept8(8);
+		case 3:	r = rept8(8);
 			break;
 		/* Sometimes pick a not-so-random number. */
-		case 5:	return get_interesting_value();
+		case 4:	return get_interesting_value();
 		}
 
 		/* limit the size */
-- 
1.9.1

                 reply	other threads:[~2015-03-06 22:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1425680999-28404-1-git-send-email-tyson.w.smith@gmail.com \
    --to=tyson.w.smith@gmail.com \
    --cc=davej@codemonkey.org.uk \
    --cc=trinity@vger.kernel.org \
    --cc=tysmith@motorola.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).