[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: sys_errlist deprecated? (ITS#3111)

I've added autodetect support.  Please test.

I'll be adding a STRERROR_R macro shortly.


At 10:13 AM 4/24/2004, Kurt@OpenLDAP.org wrote:
>I think I'd like to commit a macro (and autodetection)
>which follows the following prototype:
>        const char * STRERROR_R(n,b,s)
>Will use strerror_r (either version) if available in normal
>libc (e.g, will ignore strerror_r only in threading libraries)
>and its flavor detectable.  Otherwise, will use sys_errlist
>if available.  Otherwise, strerror.
>At 08:19 AM 4/24/2004, ando@sys-net.it 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 
>>of course).
>>    SysNet - via Dossi,8 27100 Pavia Tel: +390382573859 Fax: +390382476497