[Date Prev][Date Next]
Re: sys_errlist deprecated? (ITS#3111)
Some else to look at:
The other approach is simply to just call strerror()
directly and not worry about reentrant issues (as
we are unlikely to ever to hit them).
At 08:18 AM 4/24/2004, Pierangelo Masarati wrote:
>Kurt D. Zeilenga wrote:
>>Note that strerror_r() is not terrible portable.
>>The POSIX defn is:
>> int strerror_r(int errnum, char *strerrbuf, size_t buflen);
>This is the cleanest: only look at the buffer
>>while some systems (like Linux) use:
>>char *strerror_r(int errnum, char *buf, size_t buflen);
>This should be the most efficient, because it writes the buffer
>only if required
>>and other systems one just uses strerrror() (which on these
>>systems uses a thread specific buffer unknown error numbers).
>This is mostly what Howard suggested: strerror is likely to return
>a constant string, or "unknown error %d" in a static buffer; so if
>we don't mind about %d (because we already log it before the message)
>all we need to do is:
> char *s0 = strerror(-1), *s = strerror(e);
> if (s == s0)
> return "Unknown error";
> return s;
>However, we cannot count over this behavior forever. I have already
>reworked things to use strerror_r "consistently"; I also cleaned up things
>by not using STRERROR() at all where its result is simply ignored.
>If it is acceptable, I can commit it (and undergo review and further cleanup,
> SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497