On Thu, 2008-04-10 at 23:01 +0100, David Howells wrote: > Harvey Harrison <harvey.harrison@xxxxxxxxx> wrote: > > > > Actually, you probably _ought_ to have casts, but it should look like this: > > > > > > return (u16)p[0] | (u16)p[1] << 8; > > > > I've been looking at that thinking I needed something different, I > > believe it is ok as u8 will expand to int when shifted... correct? Or > > do I actually need the cast on each p[] term...anyone? > > Hmmm... I think you may be right: > > #include <stdio.h> > > int main() > { > unsigned char x; > printf("%u, %u\n", sizeof(x), sizeof(x << 8)); > return 0; > } > > Says: > > 1, 4 > > In which case, the cast you do have is superfluous, and casting the retrievals > is unnecessary. Expands to int, not unsigned int, I think that cast is still needed? Harvey -- To unsubscribe from this list: send the line "unsubscribe linux-arch" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html