lkml.org 
[lkml]   [2006]   [Jun]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] Fix an inproper alignment accessing in irda protocol stack
From
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/

\
 
 \ /
  Last update: 2006-06-09 07:04    [W:0.033 / U:0.948 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site