Re: [PATCH] Redudant initilization
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Bruce Momjian <bruce@momjian.us>
Cc: Ranier Vilela <ranier.vf@gmail.com>,
Kyotaro Horiguchi <horikyota.ntt@gmail.com>,
Pg Hackers <pgsql-hackers@postgresql.org>
Date: 2020-09-04T17:40:26Z
Lists: pgsql-hackers
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);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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.
(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.)
regards, tom lane
Commits
-
Yet more elimination of dead stores and useless initializations.
- a5cc4dab6d1d 14.0 landed
-
Remove still more useless assignments.
- 9a851039aac6 14.0 landed
-
Remove some more useless assignments.
- 38a2d703298c 14.0 landed