Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id C20B740DB0D for ; Wed, 28 Mar 2012 13:56:39 -0300 (ADT) Received: from mailout-de.gmx.net ([213.165.64.23]) by magus.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1SCwAm-0003qf-9V for pgsql-hackers@postgresql.org; Wed, 28 Mar 2012 16:56:38 +0000 Received: (qmail invoked by alias); 28 Mar 2012 16:56:22 -0000 Received: from a88-115-218-87.elisa-laajakaista.fi (EHLO [10.0.0.108]) [88.115.218.87] by mail.gmx.net (mp037) with SMTP; 28 Mar 2012 18:56:22 +0200 X-Authenticated: #495269 X-Provags-ID: V01U2FsdGVkX19dv70SjfpdCypjtA/L3LuIakbp9j3X2yzIgy9lsb RGLcoVjWXP73aA Message-ID: <1332953781.14371.5.camel@vanquo.pezone.net> Subject: Re: [COMMITTERS] pgsql: Remove dead assignment From: Peter Eisentraut To: Tom Lane Cc: pgsql-hackers@postgresql.org Date: Wed, 28 Mar 2012 19:56:21 +0300 In-Reply-To: <16440.1332791632@sss.pgh.pa.us> References: <15768.1332789342@sss.pgh.pa.us> <1332790159.3800.8.camel@vanquo.pezone.net> <16440.1332791632@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.2-1 Content-Transfer-Encoding: 8bit Mime-Version: 1.0 X-Y-GMX-Trusted: 0 X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/1729 X-Sequence-Number: 205610 On mån, 2012-03-26 at 15:53 -0400, Tom Lane wrote: > Peter Eisentraut 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.