xfs
[Top] [All Lists]

Re: [PATCH v3, 07/16] xfsprogs: metadump: use pointers in generate_obfus

To: Alex Elder <aelder@xxxxxxx>
Subject: Re: [PATCH v3, 07/16] xfsprogs: metadump: use pointers in generate_obfuscated_name()
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Thu, 24 Feb 2011 12:47:12 +1100
Cc: xfs@xxxxxxxxxxx
In-reply-to: <201102182121.p1ILL1AZ029097@xxxxxxxxxxxxxxxxxxxxxx>
References: <201102182121.p1ILL1AZ029097@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Fri, Feb 18, 2011 at 03:21:01PM -0600, Alex Elder wrote:
> Switch from using array references to using pointers to refer to the
> pathname characters as they get generated.  Also limit the scope of
> a few automatic variables.
> 
> Signed-off-by: Alex Elder <aelder@xxxxxxx>
> 
> The only update since the last post version is the addition of an
> ASSERT() in the loop generating the last 5 bytes.

One small comment below, otherwise:

Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>

> @@ -500,16 +502,17 @@ generate_obfuscated_name(
>                */
>               newhash = rol32(newhash, 3) ^ hash;
>  
> +             first = newp;
>               high_bit = 0;
> -             for (i = 5; i > 0; i--) {
> -                     int shift = (i - 1) * 7;
> -
> -                     newp[namelen - i] = ((newhash >> shift) & 0x7f) ^ 
> high_bit;
> -                     if (is_invalid_char(newp[namelen - i])) {
> -                             newp[namelen - i] ^= 1;
> +             for (shift = 28; shift >= 0; shift -= 7) {
> +                     *newp = (newhash >> shift & 0x7f) ^ high_bit;

I'd prefer not to have to refer to my C bible to remind myself what
the precedence of ">>" vs "&" is, so perhaps leaving the second set
of () in this statement would be a good idea.

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>