Re: [RFC v2] Documentation about unaligned memory access

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 	void myfunc(u8 *data, u32 value)
> 	{
> 		[...]
> 		value = cpu_to_le32(value);
> 		put_unaligned(value, data);

> 	u32 value = get_unaligned(data);

Actually, this is wrong. put_unaligned and get_unaligned use the type of
the "data" pointer, e.g. on powerpc get_unaligned does just "*data".

Hence, here you'll want to use

	put_unaligned(value, (u32 *)data);

and

	u32 value = get_unaligned((u32 *)data);

or you end up with a single-byte store/load.

johannes

Attachment: signature.asc
Description: This is a digitally signed message part


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux