Grant Grundler wrote:
> On Tue, Oct 17, 2006 at 11:12:56PM -0400, Adam Kropelin wrote:
> ...
>> Write the code in userspace to prove it to yourself if you don't
>> believe me. In fact, here. I did it for you. (x86 32 bit assumed;
>> adjust to taste)
>
> Thanks for the test code.
> I'll resubmit with a patch that works for 32-bit extracts/implements
> and integrate the more useful comments from this thread.
>
> With just 1ULL and the original test, I get:
> [EMAIL PROTECTED]:~$ ./test_extract
> broken=0x61626364, working=0x00000000
>
> The test code didn't attempt to correct for endianess...so the bytes
> are backwards on gsyprf11. But 32-bit extract fails for offsets
> 1-7 like I expected.

Interesting. I'll fully admit to not having enough 64 bit arch 
experience to have predicted that, but that's why I like to unit test 
that sort of thing.

> I've rewritten the test to cover a few more cases.
> And I've fixed the algorithm to handle 32-bit extracts in the test
> below and will submit the same code in the next patch.

Yup, that works fine here, thanks!

Two other thoughts...

Am I the only one who thinks...
    offset &= 8 - 1;
...is less clear than...
    offset &= 7;
...?

When I see "& 7" I think, "Oh, clearly grabbing the 3 LSb". When I see 
"& 8-1" I think, "Huh...oh, wait, that's just '& 7'". Alternatively, "% 
8", and let the compiler make the optimization for us.

Secondly, do we care that in certain cases we'll be dereferncing memory 
beyond the end of the user's buffer? We mask it all off, so it doesn't 
really matter in the end but it'd sure be unpleasant if we hit a fault 
or a hw register or something. Too unlikely to care about or downright 
impossible?

--Adam


-------------------------------------------------------------------------
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