Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero. - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.
Date
Msg-id 17114.1133471180@sss.pgh.pa.us
Whole thread Raw
In response to Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.  (Bruce Momjian <pgman@candle.pha.pa.us>)
Responses Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.  (Bruce Momjian <pgman@candle.pha.pa.us>)
List pgsql-hackers
Bruce Momjian <pgman@candle.pha.pa.us> writes:
> Should I just change them all to:

>     errno = 0;  /* avoid checking result for failure */

No, that's still a completely inaccurate description of the reason
for having the statement.

> or should I add a macro to c.h as:

>     /* Sometimes we need to clear errno so we can check errno
>      * without having to check for a failure value from the function
>      * call.
>      */    
>     #define CLEAR_ERRNO \\
>     do { \
>         errno = 0; \\
>     while (0);

I vote "neither".  Anyone who doesn't understand what this is for will
need to go read the C library man pages for a bit anyway.  Nor do I find
"CLEAR_ERRNO" an improvement over "errno = 0".
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: generalizing the planner knobs
Next
From: Bruce Momjian
Date:
Subject: Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.