[PATCH] D20903: Make system_error::message() thread safe. Fixes PR25598.

Erik Kessler via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 13 23:01:59 PDT 2016


erik65536 added a comment.

> The POSIX version of strerror_r() returns 0 on success, and any other value indicates an error (Reference <http://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html>).


I should have been more explicit when I wrote this recommendation. Checking if `strerror_r` returns -1 is not portable. For example, OSX and FreeBSD return an error code from `strerror_r` without setting `errno`. The POSIX version should check for success by checking to see if `strerror_r` returns 0. If the function fails and the return value is not -1, assume that the return value is an error code.


http://reviews.llvm.org/D20903





More information about the cfe-commits mailing list