Re: linux-2.1.106-ac3-ac4: Some weirdness in fs/ext/ patches

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Mon, 22 Jun 1998 09:46:12 +0200 (MET DST)


Bill Hawes wrote:
>
> Horst von Brand wrote:
>
> > OTOH, in the above mentioned part of the patch I see that the following
> > line is being added to truncate.c:
> >
> > static u32 le32_zero = cpu_to_le32(0);
> >
> > I don't see any possible changes in the representation of 0 when going from
> > big to little endian ;) Anyway, this kind of stuff should be #defined as a
> > constant, if really needed.
>
> The original code went to the trouble of converting endian-ness for 0, so I
> thought it best to keep this in place. Who knows, perhaps some future
> architecture will need it.

Anyway, a compiler that can't optimize that away does not deserve to
compile in this world.

It is also a case of documenting where these endianness conversions
should take place.

Say you encounter this place in the code, and want to change the 0 to
a 1. Go ahead. If you delete the cpu_to_le32, you'll end up with
surprises later on, on machines that you don't own.

Personally I'd write

#define LE32_ZERO cpu_to_le32(0)

That allows the CPU to optimize it away completely (on machines of
both endiannesses).

Roger.

-- 
Actor asks a collegue: "To what do you owe your success in acting?"
Answer: "Honesty. Once you've learned how to fake that, you've got it made."
-------- Custom Linux device drivers for sale! Call for a quote. ----------
Email: R.E.Wolff@BitWizard.nl || Tel: +31-15-2137555 || FAX: +31-15-2138217

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu