pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter_e@gmx.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@postgresql.org
Subject: Re: [COMMITTERS] pgsql: Remove dead assignment
Date: Wed, 28 Mar 2012 19:56:21 +0300
Message-ID: <1332953781.14371.5.camel@vanquo.pezone.net> (raw)
In-Reply-To: <16440.1332791632@sss.pgh.pa.us>
References: <E1SCEd4-0006qd-Qd@gemulon.postgresql.org>
	<15768.1332789342@sss.pgh.pa.us>
	<1332790159.3800.8.camel@vanquo.pezone.net>
	<16440.1332791632@sss.pgh.pa.us>

On mån, 2012-03-26 at 15:53 -0400, Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > On mån, 2012-03-26 at 15:15 -0400, Tom Lane wrote:
> >> I also do not think it does anything for readability for this call
> >> of read_info() to be unexpectedly unlike all the others. 
> 
> > I do not think that it is good code quality to assign something to a
> > variable and then assign something different to a variable later in the
> > same function.
> 
> Well, that's a totally different issue, because if we had used a
> different variable for the other purpose, this assignment would
> still be dead and coverity would still be whinging about it, no?

Let's look at this differently.  If this code were written from scratch
now, it might have turned out like this:

Form_pg_sequence old_seq, seq;

...
old_seq = read_info(elm, seq_rel, &buf);
...
seq = (Form_pg_sequence) GETSTRUCT(tuple);

But that gets a complaint from gcc:

sequence.c:248:19: error: variable ‘old_seq’ set but not used [-Werror=unused-but-set-variable]

So when faced with this, what is the right fix?  (Probably not assigning
the useless return value to some other variable used for a different
purpose.)

> The problem that I have with this change (and the similar ones you've
> made elsewhere) is really that it's only chance that the code isn't
> fetching anything from the result of read_info.

What other changes are you referring to?  I don't recall any similar
ones and don't find any in the logs.





view thread (6+ messages)  latest in thread

Message-ID: <1332953781.14371.5.camel@vanquo.pezone.net>
Permalink:  ../1332953781.14371.5.camel@vanquo.pezone.net/
Also on:    postgresql.org/message-id/1332953781.14371.5.camel@vanquo.pezone.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter_e@gmx.net, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
  Subject: Re: [COMMITTERS] pgsql: Remove dead assignment
  In-Reply-To: <1332953781.14371.5.camel@vanquo.pezone.net>
  References: <E1SCEd4-0006qd-Qd@gemulon.postgresql.org> <15768.1332789342@sss.pgh.pa.us> <1332790159.3800.8.camel@vanquo.pezone.net> <16440.1332791632@sss.pgh.pa.us> <1332953781.14371.5.camel@vanquo.pezone.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox