libftdi Archives

Subject: Re: variable shadowing

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Fri, 26 Sep 2014 17:22:32 +0200
Hi Xan,

On Sunday, 14. September 2014 10:38:36 xantares 09 wrote:
> in ftdi_stream.c:155, the return code declaration at beginnign of
> ftdi_readstream int err = 0;
> is overriden by at line 243 by:
> 
> do
>     {
>         FTDIProgressInfo  *progress = &state.progress;
>         const double progressInterval = 1.0;
>         struct timeval timeout = { 0, ftdi->usb_read_timeout };
>         struct timeval now;
> 
>         int err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
>         if (err ==  LIBUSB_ERROR_INTERRUPTED)
>             /* restart interrupted events */
>             err = libusb_handle_events_timeout(ftdi->usb_ctx, &timeout);
> 
> 
> if the final return code should depend on the return code of
> libusb_handle_events_timeout, it's a bug, if not a different name should
> be chosen.

thanks for reporting this issue, I've applied your patch.

I think you are right, we should probably change "int err ="
to just "err =".

@Uwe: Do you agree? It's your code :)


Also, looking closely at that code, it calls libusb_handle_events_timeout() 
again on LIBUSB_ERROR_INTERRUPTED. But it does that only *once*.
Is that intentional? What if the system is temporarily really busy?


Thanks to the Shellshock bash bug my time schedules were a bit messed up.
So I guess we won't have a libftdi release at the end of September.
(I'll also be AFK for a few days, too)

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread