libusbx v1.0.9-rc4 is now available

Pete Batard pete at akeo.ie
Fri Mar 30 10:53:12 EDT 2012


On 2012.03.30 15:33, Sean McBride wrote:
> You're not fixing anything, you're just tricking the compiler into not warning you about a real problem.

Unless we expect to deal with 4 GB of data, I don't see it as a real 
problem, which is what I considered in the proposed fix. And if we do, 
then our method won't work on 32 bit, because we'll have 32 bit 
truncation on the pointer itself.

Can you elaborate on the real problem you see here?

> You're still throwing away half the bits of arg0

Yes, but I am doing so willingly, because I don't ever expect to need 
them. Looking at bug 117 (which I wasn't aware of) it seems this point 
of view is shared by Nathan:

"I doubt a usb transaction will ever be more than 232 bytes so it is 
safe to just write a 32 bit value (for now)."

We will need to deal with transactions of more than 4 GB at once for the 
proposed fix to fail, which I don't see as realistic. But I wouldn't 
mind hearing if anybody thinks we may have to handle such a case.

> and now you've also discarded the automated TODO the compiler was giving us.

Not exactly. I've addressed the TODO as should have been done a long 
time ago (when the issue was reported, not months later, but this is 
mostly due to libusb's maintainership issues).

I do agree with using sizeof(var) rather than sizeof(type), which is the 
proper way to go.

But the real question is: do you ever expect the size provided in arg0 
to need to be more than 32 bit? If not, then I will argue that the TODO 
has been addressed.

> IMNSHO:
>   - the warning should stay
>   - a TODO comment should be added referencing bug #117
>   - an assert should check that size is<  UINT32_MAX

Disagree for #1 and #2. I don't really see the need for 3, but it 
doesn't hurt, so I don't mind adding it.

Regards,

/Pete



More information about the libusbx mailing list