Re: [PATCH] mdadm 2.5 (Was: ANNOUNCE: mdadm 2.5 - A tool for managing Soft RAID under Linux)

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

 



On Thursday June 1, eyal@xxxxxxxxxxxxxx wrote:
> Alex Davis wrote:
> >>short swap16(short in)
> >>{
> >>       int i;
> >>       short out=0;
> >>       for (i=0; i<4; i++) {
> >>               out = out<<8 | (in&255);
> >>               in = in >> 8;
> >>       }
> >>       return out;
> >>}
> > 
> > Shouldn't that be "for (i=0; i<2; i++) {..." ? 

Well, yes... if you want the code to actually work, I guess that might
be an improvement....


> 
> In which case, do we really need this complexity rather than
> a clear swap, e.g.
> 	return (short)(((in&0x0ff)<<8) | ((in>>8)&0x0ff))

What I like about the above is that the difference between swap16,
swap32 and swap64 is just one number.  In this case I think clarity
and maintainability are much more important than efficiency.

Thanks for the comment,
NeilBrown
-
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux