Re: Coverity Open Source Defect Scan of PostgreSQL

From: Greg Stark <gsstark(at)mit(dot)edu>
To: ben(at)coverity(dot)com
Cc: Martijn van Oosterhout <kleptog(at)svana(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <gsstark(at)mit(dot)edu>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Neil Conway <neilc(at)samurai(dot)com>, Andreas Pflug <pgadmin(at)pse-consulting(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Coverity Open Source Defect Scan of PostgreSQL
Date: 2006-03-08 23:42:45
Message-ID: 87lkvkmrka.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Ben Chelf <ben(at)coverity(dot)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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2006-03-08 23:55:59 Re: Merge algorithms for large numbers of "tapes"
Previous Message Dann Corbit 2006-03-08 23:35:53 Re: Merge algorithms for large numbers of "tapes"