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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.
Date: 2005-12-01 21:06:20
Message-ID: 17114.1133471180@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Bruce Momjian 2005-12-01 21:11:58 pgsql: Comment "errno = 0" in a more generic way.
Previous Message Bruce Momjian 2005-12-01 21:00:15 Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-12-01 21:12:30 Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.
Previous Message Tom Lane 2005-12-01 21:01:34 Re: generalizing the planner knobs