Re: [PATCH] Fix an inproper alignment accessing in irda protocolstack

From: David Miller
Date: Fri Jun 09 2006 - 01:01:16 EST


From: "Luke Yang" <luke.adi@xxxxxxxxx>
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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/