Re: Coverity Open Source Defect Scan of PostgreSQL - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Coverity Open Source Defect Scan of PostgreSQL
Date
Msg-id 87lkvkmrka.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Coverity Open Source Defect Scan of PostgreSQL  (Ben Chelf <ben@coverity.com>)
Responses Re: Coverity Open Source Defect Scan of PostgreSQL  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
Ben Chelf <ben@coverity.com> writes:

> >>>#ifdef STATIC_ANALYSIS
> >>>#define ereport(elevel, rest)  \
> >>>        (errstart(elevel, __FILE__, __LINE__, PG_FUNCNAME_MACRO) ? \
> >>>         (errfinish rest) : (void) 0), (elevel >= ERROR ? exit(0) : 0)
> >>>#else
> >>>/* Normal def */
> >>>#endif
> 
> As for Coverity, if the elevel that's passed to the ereport is really a
> constant, the above #ifdef should absolutely do the trick for us so we know to
> stop analyzing on that path...Let me know if it doesn't actually do that ;)

If you're willing to require elevel to always be a constant then why not just
tack on the (elevel >= ERROR ? exit(0) : 0) onto the end of the regular
definition of ereport instead of having an ifdef?

Incidentally, if it's not guaranteed to be a constant then the definition
above is wrong because it's missing parentheses around elevel at both
occurrences.

-- 
greg



pgsql-hackers by date:

Previous
From: "Dann Corbit"
Date:
Subject: Re: Merge algorithms for large numbers of "tapes"
Next
From: Greg Stark
Date:
Subject: Re: Merge algorithms for large numbers of "tapes"