Messages in this thread |  | | Date | Thu, 08 Jun 2006 22:01:25 -0700 (PDT) | Subject | Re: [PATCH] Fix an inproper alignment accessing in irda protocol stack | From | David Miller <> |
| |
From: "Luke Yang" <luke.adi@gmail.com> Date: Fri, 9 Jun 2006 11:45:06 +0800
> /* Construct new discovery info to be used by IrLAP, */ > - u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word; > +#ifdef __LITTLE_ENDIAN > + irlmp->discovery_cmd.data.hints[0] = irlmp->hints.word & 0xff; > + irlmp->discovery_cmd.data.hints[1] = (irlmp->hints.word & 0xff00) >> 8; > +#else /* ifdef __BIG_ENDIAN */ > + irlmp->discovery_cmd.data.hints[0] = (irlmp->hints.word & 0xff00) >> 8; > + irlmp->discovery_cmd.data.hints[1] = irlmp->hints.word & 0xff; > +#endif
Please don't add ugly ifdefs, they are not necessary.
You can use the le16_to_cpu() macro on the hints.word datum, then pick out the byte you need, as necessary. That way you don't need to use ifdefs.
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
|  |