On Mon, Jan 12, 2004 at 02:44:10AM +0100, [EMAIL PROTECTED] wrote: > Hmm. I am not precisely happy with improvements like > > - ptr[4] = MSB_of(info->pagesize>>16); > - ptr[5] = LSB_of(info->pagesize>>16); > - ptr[6] = MSB_of(info->pagesize&0xFFFF); > - ptr[7] = LSB_of(info->pagesize&0xFFFF); > + ((u32 *) ptr)[1] = cpu_to_be32(info->pagesize); > > A good compiler generates the same code, and for a human > like me the above four statements show much more clearly > that values are assigned to ptr[4..7] than the ugly cast below.
Actually, I think the new way is more readable. And, apparently, so does Alan. Considering he contributes an amazing amount of code on a regular basis, I'm inclined to go with his way. > > + ((u16*)ptr)[0] = sizeof(mode_page_01) - 2; > > looks like a bug. This (u16*) will work or not, depending on > whether the machine is big or little-endian. That's definately a bug. Greg, could you add a cpu_to_be16() to the right-hand side of that (around everything)? Matt -- Matthew Dharm Home: [EMAIL PROTECTED] Maintainer, Linux USB Mass Storage Driver S: Another stupid question? G: There's no such thing as a stupid question, only stupid people. -- Stef and Greg User Friendly, 7/15/1998
pgp00000.pgp
Description: PGP signature