Oliver Neukum <[EMAIL PROTECTED]> writes:
> Am Donnerstag, 8. Februar 2007 16:41 schrieb Sergei Organov:
>> > If you do that, le16 is just as valid, especially if declared
>> > unaligned.
>> 
>> I don't think so:
>> 
>> 1. 'unsigned char', be it used in the form of 'u8' or not, has neither
>>    alignment nor endianness problems, while le16 has both.
>
> By simply ignoring the issue.

Which one? Endianness? As one can't solve this issues with C types and
needs *code* to solve it anyway, le16 doesn't help here either. Or am I
missing something and somebody has already invented some kernel trick
that automatically converts types marked 'bitwise' to/from correct
endianness?

>
>> 2. The only truth that le16 actually tells to the compiler is that this
>>    field is 2 bytes in size, and u8[2] tells that either. However, the
>
> No, that tells the compiler it's two fields of 1 byte each.

It actually says both, so your "no" above is incorrect:

First, it is an array having size=2:

struct s { u8 foo[2] } s;
sizeof(s.foo) == 2

so it *does* say that 'foo' is 2 bytes in size.

Second, it does say that this field could be further split into 2 bytes,
but one needs this split anyway when performing endianness
conversion, so this also matches the intended use of the field. Though
the following struct plus conversion routines could be even better:

  struct le2 { u8 lo; u8 hi; }

>>    u8[2] definition makes it hard to use this field as bare integer by
>>    mistake, so IMHO it wins from the POV of type-safety as well.
>
> It is an integer. le16 was introduced to avoid u16.

Well, I must admit I've first overlooked the 'bitwise' attribute of it,
and that indeed makes le16 better than u16, but I still fail to see how
it makes it better than u8[2] in this particular case. To be picky, u16
is an integer, but le16 is not an integer anymore, exactly due to the
'bitwise' attribute, and u8[2] is even less an integer, so it IMHO still
wins.

I think we are already close to agree to disagree ;)

-- Sergei.


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to