Re: [PATCH v2 4/5] staging: r8188eu: restricted __be16 degrades to int

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

 



On 21/08/20 05:10PM, Fabio M. De Francesco wrote:
> Building on the objections you had from Greg I suggest that, before attempting 
> anew to address problems like these, you get a better understanding of the topics of 
> native and network endianness and of the API that (conditionally) swap bytes 
> in a variable between little endian and big endian representation.
> 
> To start with, please note that the following code leads to tests for "v.vub[0] == 0xDD" 
> which is true on little endian architectures while "v.vub[0] == 0xAA" is true on big 
> endian ones...
> 
> union {
>         u32 vud;
>         u8 vub[4];
> } v;
> 
> v.vud = 0xAABBCCDD;
> 
> Also note that API like cpu_to_be32(), htonl(), be32_to_cpu(), ntohl, and the likes are 
> used to (conditionally) swap bytes (i.e., change the arrangement of the bytes in a 
> multi-bytes variable).
> 
> Casts have very different purposes and usage patterns and, above all, they cannot 
> magically change the endianness of a variable.
> 
> Regards,
> 
> Fabio
> 

Thanks for the explanation Fabio!
Will rework and send it through!

Thanks,
Aakash Hemadri




[Index of Archives]     [Linux Driver Development]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux