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

Re: Further news on Clang - spurious warnings

From: Peter Geoghegan <peter(at)2ndquadrant(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Further news on Clang - spurious warnings
Date: 2011-08-03 11:44:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On 3 August 2011 12:19, Heikki Linnakangas
<heikki(dot)linnakangas(at)enterprisedb(dot)com> wrote:

> Right, but the purpose of that check is to defend from programmer error. If
> the programmer screws up and calls "PQresStatus(-1)", we want to give an
> error, not crash. If you assume that the programmer will only pass a valid
> enum constant as parameter, then you might as well remove the if-statement
> altogether. I don't think that would be an improvement.

Ahh. I failed to consider the intent of the code.

Attached patch has a better solution than casting though - we simply
use an enum literal. The fact that PGRES_EMPTY_QUERY is the first
value in the enum can be safely assumed to be stable, not least
because we've even already explicitly given it a corresponding value
of 0.

Peter Geoghegan
PostgreSQL Development, 24x7 Support, Training and Services

Attachment: remove_tautology.v2.patch
Description: text/x-patch (538 bytes)

In response to


pgsql-hackers by date

Next:From: davegDate: 2011-08-03 11:57:31
Subject: Re: error: could not find pg_class tuple for index 2662
Previous:From: Heikki LinnakangasDate: 2011-08-03 11:19:29
Subject: Re: Further news on Clang - spurious warnings

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