Re: [PATCH] Redudant initilization

Ranier Vilela <ranier.vf@gmail.com>

From: Ranier Vilela <ranier.vf@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Bruce Momjian <bruce@momjian.us>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2020-09-05T16:40:37Z
Lists: pgsql-hackers

Attachments

Em sex., 4 de set. de 2020 às 18:20, Ranier Vilela <ranier.vf@gmail.com>
escreveu:

> Em sex., 4 de set. de 2020 às 14:40, Tom Lane <tgl@sss.pgh.pa.us>
> escreveu:
>
>> Bruce Momjian <bruce@momjian.us> writes:
>> > I have to say, I am kind of stumped why compilers do not warn of such
>> > cases, and why we haven't gotten reports about these cases before.
>>
>> I was just experimenting with clang's "scan-build" tool.  It finds
>> all of the cases you just fixed, and several dozen more beside.
>> Quite a few are things that, as a matter of style, we should *not*
>> change, for instance
>>
>> rewriteHandler.c:2807:5: warning: Value stored to 'outer_reloids' is
>> never read
>>                                 outer_reloids =
>> list_delete_last(outer_reloids);
>>                                 ^
>>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
> There are some like this, in the analyzes that I did.
> Even when it is the last action of the function.
>
>
>> Failing to update the list pointer here would just be asking for bugs.
>> However, I see some that look like genuine oversights; will go fix.
>>
> Thanks for fixing this.
>
>
>> (I'm not sure how much I trust scan-build overall.  It produces a
>> whole bunch of complaints about null pointer dereferences, for instance.
>> If those aren't 99% false positives, we'd be crashing constantly.
>> It's also dog-slow.  But it might be something to try occasionally.)
>>
> I believe it would be very beneficial.
>
> Attached is a patch I made in March/2020, but due to problems,
> it was sent but did not make the list.
> Would you mind taking a look?
> Certainly, if accepted, rebasing would have to be done.
>
Here it is simplified, splitted and rebased.
Some are bogus, others are interesting.

regards,
Ranier Vilela

Commits

  1. Yet more elimination of dead stores and useless initializations.

  2. Remove still more useless assignments.

  3. Remove some more useless assignments.