Tom Lane wrote:
> Bruce Momjian <pgman@candle.pha.pa.us> writes:
> > ! #ifdef STRERROR_R_INT
> > ! /* SUSv3 version */
> > ! if (strerror_r(errnum, strerrbuf, buflen) == 0)
> > ! return strerrbuf;
> > ! else
> > ! return NULL;
> > ! #else
>
> This code will dump core if strerror_r ever fails, which seems like
> a bad idea. I suggest that it be like
>
> ! if (strerror_r(errnum, strerrbuf, buflen) == 0)
> ! return strerrbuf;
> ! else
> ! return "strerror_r failed";
>
> which at least gives a hint of the problem ...
I assume all the callers have to check for NULL, rather than supply a
dummy string. However, are you saying that this is more of a debug tool
and should never fail to return a usable value?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073