Skip site navigation (1) Skip section navigation (2)

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

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(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:12:30
Message-ID: 200512012112.jB1LCUw27604@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-committerspgsql-hackers
Tom Lane wrote:
> 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".

Well, there seems to be enough confusion, even in this email list, that
identifying _why_ errno is being cleared is a good idea.

I modified it to:

        errno = 0;  /* avoid having to check the result for failure */

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman(at)candle(dot)pha(dot)pa(dot)us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

In response to

Responses

pgsql-hackers by date

Next:From: Pollard, MikeDate: 2005-12-01 21:14:11
Subject: Re: generalizing the planner knobs
Previous:From: Tom LaneDate: 2005-12-01 21:06:20
Subject: Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.

pgsql-committers by date

Next:From: Bruce MomjianDate: 2005-12-01 21:16:14
Subject: pgsql: Add comment to pg_atoi.
Previous:From: Bruce MomjianDate: 2005-12-01 21:11:58
Subject: pgsql: Comment "errno = 0" in a more generic way.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group