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

Re: ldap_err2string format



At 01:24 PM 6/19/00 -0400, Mark Smith wrote:
>I generally agree with your comments, and this should be clarified when
>we revise the C API I-D.
>
>But ldap_err2string() may or may not be thread safe, depending on how it
>is implemented.

Which means that applications must assume that it is not thread
safe unless they have specific knowledge regarding the current
implementation.

>If an implementation returns a pointer to static,
>readonly data or to thread specific data, ldap_err2string() should be
>thread safe).

strerror() is not thread safe because it allows the implementation
to dynamically create the string in the static, readonly (to caller)
space, e.g: "unknown error (666)".  Same would follow for
ldap_err2string().

>Also, I don't understand what this sentence from your suggested text is
>intended to convey:
>>    The implementation behaves as if no
>>    library calls the ldap_err2string function.

That's straight from Standard C Library spec for strerror().
It implies that if the caller makes a call to strerror() followed
by some other library call (such as printf or strcpy) that the
string will not change until the caller makes a subsequent
strerror() call.  Without this requirement:

	char *s = strerror(errno);
	printf("%s\n", s);

might not print the value of s at the time of the strerror
call.  That is, printf is not allowed to call strerror itself
and trash the string before printing the string.

Kurt