2012/10/15 Sean McBride <s...@rogue-research.com>:
> On Sat, 13 Oct 2012 20:35:24 +0200, Ludovic Rousseau said:
>
>>> /Users/xiaofanc/work/libusbx/ludovic/libusbx/libusb/io.c:1877:35:
>>> Implicit conversion loses integer precision: 'long' to 'int'
>>>       timeout_ms = (tv->tv_sec * 1000) + (tv->tv_usec / 1000);
>>
>>It is fixed in https://github.com/LudovicRousseau/libusbx/commit/
>>1680d0d43a7b0caa3ad024f66729f33ec1a557f1
>>
>>I think this patch can go upstream.
>
> I think it would be better to change 'timeout_ms' to 'long' then 
> force-truncate it later only when/if necessary, like so:
>
> <https://github.com/seanm/libusbx/commit/8b8545c26ba2246d4589b4115ee175d4a8ce4358>

I don't know why your code would be better. Maybe it is but you should explain.

One problem with your code is that the value used for the debug may
not be the value really used if an integer overflow occurs.
You log "timeout_ms" but the function then uses "(int)timeout_ms".

I agree that if an integer overflow occurs we may have other problems.
And that would be a really big timeout (~24 days).

Bye

-- 
 Dr. Ludovic Rousseau

------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to