strerror_r: enforce POSIX recommendations
authorEric Blake <eblake@redhat.com>
Wed, 18 May 2011 21:19:51 +0000 (15:19 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 24 May 2011 19:42:32 +0000 (13:42 -0600)
commit3a3fe58b91a00ba3cafd960a2e2355c842448e47
tree2843f38d38b3c3cdcd8372fe816bed4b0effac3b
parent734bedd126553e3619936f4fa84bf4854b7c40d6
strerror_r: enforce POSIX recommendations

POSIX recommends (but does not require) that strerror_r populate
buf even on error.  But since we guarantee this behavior for
strerror, we might as well also guarantee it for strerror_r.

* lib/strerror_r.c (safe_copy): New helper method.
(strerror_r): Guarantee a non-empty string.
* tests/test-strerror_r.c (main): Enhance tests to incorporate
recent POSIX rulings and to match our strerror guarantees.
* doc/posix-functions/strerror_r.texi (strerror_r): Document this.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/posix-functions/strerror_r.texi
lib/strerror_r.c
tests/test-strerror_r.c