* [PATCH v3, 06/16] xfsprogs: metadump: replace repeated blocks with a loop
@ 2011-02-18 21:21 Alex Elder
2011-02-24 1:40 ` Dave Chinner
0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2011-02-18 21:21 UTC (permalink / raw)
To: xfs
Each of the last five characters in the obfuscated name are
generated the same way. Replace that repeated block of code
with an equivalent loop.
Signed-off-by: Alex Elder <aelder@sgi.com>
No significant changes in this version from the last one posted.
---
db/metadump.c | 43 +++++++++----------------------------------
1 file changed, 9 insertions(+), 34 deletions(-)
Index: b/db/metadump.c
===================================================================
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -501,41 +501,16 @@ generate_obfuscated_name(
newhash = rol32(newhash, 3) ^ hash;
high_bit = 0;
+ for (i = 5; i > 0; i--) {
+ int shift = (i - 1) * 7;
- 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 - 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;
+ newp[namelen - i] = ((newhash >> shift) & 0x7f) ^ high_bit;
+ if (is_invalid_char(newp[namelen - i])) {
+ newp[namelen - i] ^= 1;
+ high_bit = 0x80;
+ } else
+ high_bit = 0;
+ }
/*
* If we flipped a bit on the last byte, we need to
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v3, 06/16] xfsprogs: metadump: replace repeated blocks with a loop
2011-02-18 21:21 [PATCH v3, 06/16] xfsprogs: metadump: replace repeated blocks with a loop Alex Elder
@ 2011-02-24 1:40 ` Dave Chinner
0 siblings, 0 replies; 2+ messages in thread
From: Dave Chinner @ 2011-02-24 1:40 UTC (permalink / raw)
To: Alex Elder; +Cc: xfs
On Fri, Feb 18, 2011 at 03:21:01PM -0600, Alex Elder wrote:
> Each of the last five characters in the obfuscated name are
> generated the same way. Replace that repeated block of code
> with an equivalent loop.
>
> Signed-off-by: Alex Elder <aelder@sgi.com>
Nice simplification.
Reviewed-by: Dave Chinner <dchinner@redhat.com>
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-24 1:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-18 21:21 [PATCH v3, 06/16] xfsprogs: metadump: replace repeated blocks with a loop Alex Elder
2011-02-24 1:40 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox