Re: Being more careful about iospace accesses..

From: David Woodhouse
Date: Thu Sep 16 2004 - 06:58:05 EST


On Thu, 2004-09-16 at 01:10 +0100,
viro@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx wrote:
> On Wed, Sep 15, 2004 at 04:26:12PM -0700, Linus Torvalds wrote:
>
> > other bitwise type. You'd get a warnign about incompatible types. Makes
> > sense, no?
> > - you can only do operations that are safe within that byte order. For
> > example, it is safe to do a bitwise "&" on two __le16 values. Clearly
> > the result is meaningful.
>
> BTW, so far the most frequent class of endianness bugs had been along the
> lines of
> foo->le16_field = cpu_to_le32(12);
> and vice versa. On big-endian it's a guaranteed FUBAR - think carefully about
> the value that will end up there.

Is that really more frequent than just 'foo->le16_field = 12' ?
I'm surprised.

Certainly, it was the frequency of pure assignment without _any_ attempt
at byte-swapping which caused me to introduce the 'jint32_t' et al
structures in jffs2, which even gcc then bitches about if you use them
wrongly.

I suppose I can ditch those now -- I always intended to after a while
anyway.

--
dwmw2


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/