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

From Alvaro Herrera
Subject Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.
Date
Msg-id 20051201212050.GB6375@surnet.cl
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>)
List pgsql-hackers
Bruce Momjian wrote:
> Tom Lane wrote:

> > > 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);

May I vote against this kind of use of macros in general?  It doesn't
add much value (actually, none in this case) and it makes the code
harder to read.  For a pathological example I can point to PHP, which is
so full of strange macros that it's very very hard to read.

Of course there are places where macros are valuable tools, but this
doesn't seem to be one of them.

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


pgsql-hackers by date:

Previous
From: "Pollard, Mike"
Date:
Subject: Re: generalizing the planner knobs
Next
From: Martijn van Oosterhout
Date:
Subject: Re: [COMMITTERS] pgsql: Add comments about why errno is set to zero.