[vlc-devel] commit: strerror(errno) is not thread-safe, use %m ( R??mi Denis-Courmont )

Rémi Denis-Courmont remi at remlab.net
Wed Oct 7 15:24:00 CEST 2009


On Wed, 7 Oct 2009 14:43:35 +0200, jpd at videolan.org wrote:
> On Wed, Oct 07, 2009 at 01:55:44PM +0200, Rafael Carre wrote:
>> Anthony Loiseau <thannoy at actech-innovation.com> a ??crit :
>> > Just a note (I have not tested anything).
>> > - strerror() conforms to C89,C99 and POSIX
>> sure, but it just is not thread safe so you shouldn't use it in VLC
> 
> AFAIK returning pointers to string constants is typically safe enough,

If you want to convince POSIX *and* glibc that they should make strerror(),
it's up to you. The fact is that strerror() is not thread-safe in the
standard, and is actually not thread-safe in glibc.

> so strerror() should be fine except when returning a pointer to a static
> buffer containing "unknown error NNN". Thus breaking only when the libc
> and system calls are out of sync.

You seem to omit that strerror() is localized.

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list