public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <aelder@sgi.com>
To: xfs@oss.sgi.com
Subject: [PATCH 4/6] xfsprogs: eliminate a pointless loop
Date: Wed, 06 Oct 2010 13:49:31 -0500	[thread overview]
Message-ID: <1286390971.1951.366.camel@doink> (raw)

Eliminate a now pointless loop.  Done as a separate patch to
make the effects of upcoming changes more clear.

Signed-off-by: Alex Elder <aelder@sgi.com>

---
 db/metadump.c |  129 ++++++++++++++++++++++++++++------------------------------
 1 file changed, 63 insertions(+), 66 deletions(-)

Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -443,80 +443,77 @@ generate_obfuscated_name(
 	if (*name == '/')
 	    	name++;
 	do {
+		uchar_t	high_bit;
+
 		dup = 0;
-		for (;;) {
-			uchar_t	high_bit;
 
-		    	/*
-			 * The beginning of the obfuscated name can
-			 * be pretty much anything, so fill it in
-			 * with random characters.
-			 */
-			newhash = 0;
-			for (i = 0; i < namelen - 5; i++) {
-				newp[i] = random_filename_char();
-				newhash = newp[i] ^ rol32(newhash, 7);
-			}
+		/*
+		 * The beginning of the obfuscated name can be
+		 * pretty much anything, so fill it in with random
+		 * characters.
+		 */
+		newhash = 0;
+		for (i = 0; i < namelen - 5; i++) {
+			newp[i] = random_filename_char();
+			newhash = newp[i] ^ rol32(newhash, 7);
+		}
 
-			/*
-			 * Compute which five bytes need to be used
-			 * at the end of the name so the hash of the
-			 * obfuscated is the same as the hash of the
-			 * original.  If any result in an invalid
-			 * character, flip a bit and arrange for a
-			 * corresponding bit in a neighboring byte
-			 * to be flipped as well.  For the last
-			 * byte, the "neighbor" to change is the
-			 * first byte we're computing here.
-			 */
-			newhash = rol32(newhash, 3) ^ hash;
+		/*
+		 * Compute which five bytes need to be used at the
+		 * end of the name so the hash of the obfuscated is
+		 * the same as the hash of the original.  If any
+		 * result in an invalid character, flip a bit and
+		 * arrange for a corresponding bit in a neighboring
+		 * byte to be flipped as well.  For the last byte,
+		 * the "neighbor" to change is the first byte we're
+		 * computing here.
+		 */
+		newhash = rol32(newhash, 3) ^ hash;
+
+		high_bit = 0;
 
+		newp[namelen - 5] = (newhash >> 28) & 0x7f ^ high_bit;
+		if (is_invalid_char(newp[namelen - 5])) {
+			newp[namelen - 5] ^= 1;
+			high_bit = 0x80;
+		} else
 			high_bit = 0;
 
-			newp[namelen - 5] = (newhash >> 28) & 0x7f ^ high_bit;
+		newp[namelen - 4] = (newhash >> 21) & 0x7f ^ high_bit;
+		if (is_invalid_char(newp[namelen - 4])) {
+			newp[namelen - 4] ^= 1;
+			high_bit = 0x80;
+		} else
+			high_bit = 0;
+
+		newp[namelen - 3] = (newhash >> 14) & 0x7f ^ high_bit;
+		if (is_invalid_char(newp[namelen - 3])) {
+			newp[namelen - 3] ^= 1;
+			high_bit = 0x80;
+		} else
+			high_bit = 0;
+
+		newp[namelen - 2] = (newhash >> 7) & 0x7f ^ high_bit;
+		if (is_invalid_char(newp[namelen - 2])) {
+			newp[namelen - 2] ^= 1;
+			high_bit = 0x80;
+		} else
+			high_bit = 0;
+
+		newp[namelen - 1] = (newhash >> 0) & 0x7f ^ high_bit;
+		if (is_invalid_char(newp[namelen - 1])) {
+			newp[namelen - 1] ^= 1;
+			high_bit = 0x80;
+		} else
+			high_bit = 0;
+
+		if (high_bit) {
+			newp[namelen - 5] ^= 0x10;
 			if (is_invalid_char(newp[namelen - 5])) {
-				newp[namelen - 5] ^= 1;
-				high_bit = 0x80;
-			} else
-				high_bit = 0;
-
-			newp[namelen - 4] = (newhash >> 21) & 0x7f ^ high_bit;
-			if (is_invalid_char(newp[namelen - 4])) {
-				newp[namelen - 4] ^= 1;
-				high_bit = 0x80;
-			} else
-				high_bit = 0;
-
-			newp[namelen - 3] = (newhash >> 14) & 0x7f ^ high_bit;
-			if (is_invalid_char(newp[namelen - 3])) {
-				newp[namelen - 3] ^= 1;
-				high_bit = 0x80;
-			} else
-				high_bit = 0;
-
-			newp[namelen - 2] = (newhash >> 7) & 0x7f ^ high_bit;
-			if (is_invalid_char(newp[namelen - 2])) {
-				newp[namelen - 2] ^= 1;
-				high_bit = 0x80;
-			} else
-				high_bit = 0;
-
-			newp[namelen - 1] = (newhash >> 0) & 0x7f ^ high_bit;
-			if (is_invalid_char(newp[namelen - 1])) {
-				newp[namelen - 1] ^= 1;
-				high_bit = 0x80;
-			} else
-				high_bit = 0;
-
-			if (high_bit) {
-			    	newp[namelen - 5] ^= 0x10;
-			    	if (is_invalid_char(newp[namelen - 5])) {
-					newp[namelen - 1] ^= 2;
-					newp[namelen - 5] ^= 0x20;
-					ASSERT(!is_invalid_char(newp[namelen - 1]));
-				}
+				newp[namelen - 1] ^= 2;
+				newp[namelen - 5] ^= 0x20;
+				ASSERT(!is_invalid_char(newp[namelen - 1]));
 			}
-			break;
 		}
 
 		ASSERT(libxfs_da_hashname(newname, namelen) == hash);


_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

                 reply	other threads:[~2010-10-06 18:48 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=1286390971.1951.366.camel@doink \
    --to=aelder@sgi.com \
    --cc=xfs@oss.sgi.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