[vlc-devel] [vlc-commits] hls: Avoid using errno.
Hugo Beauzée-Luyssen
beauze.h at gmail.com
Mon Mar 12 16:14:52 CET 2012
On Mon, Mar 12, 2012 at 4:12 PM, Tobias Güntner <fatbull at web.de> wrote:
> Hello!
>
> Am 12.03.2012 15:07, schrieb Hugo Beauzée-Luyssen:
>>
>> value = strtol(token,&endptr, 10);
>>
>> - if (token == endptr)
>> + if (token == endptr || errno == ERANGE )
>
>
> You have to explicitly set errno to 0 before you can reliably test it.
>
> "No function in this volume of POSIX.1-2008 shall set errno to 0."
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/errno.html
>
> "The strtol() function shall not change the setting of errno if successful.
> Since 0, {LONG_MIN} or {LLONG_MIN}, and {LONG_MAX} or {LLONG_MAX} are
> returned on error and are also valid returns on success, an application
> wishing to check for error situations should set errno to 0, then call
> strtol() or strtoll(), then check errno."
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtol.html
>
> The same applies to strtof.
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtod.html
>
> Regards,
> Tobias
>
>
Woops indeed you are right. Thanks!
Regards,
--
Hugo Beauzée-Luyssen
More information about the vlc-devel
mailing list