[vlc-devel] [vlc-commits] hls: Avoid using errno.

Tobias Güntner fatbull at web.de
Mon Mar 12 16:12:05 CET 2012


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

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

The same applies to strtof.


More information about the vlc-devel mailing list