Re: [PATCH] Redudant initilization

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Redudant initilization
Date: 2020-09-05 16:40:37
Message-ID: CAEudQApUmZAJ9Dt9ubb-yXe67HsHSPsftfXXtM1Thx3_Zz=58Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

> Em sex., 4 de set. de 2020 às 14:40, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> escreveu:
>
>> Bruce Momjian <bruce(at)momjian(dot)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

Attachment Content-Type Size
fix_redudant_initialization_firstmissingnum_heaptuple.patch application/octet-stream 793 bytes
fix_redudant_initialization_offsetnumber_gistutil.patch application/octet-stream 406 bytes
fix_redudant_initialization_formatting.patch application/octet-stream 362 bytes
fix_redudant_initialization_arrayfuncs.patch application/octet-stream 933 bytes
fix_redudant_initialization_bklno_hash.patch application/octet-stream 2.3 KB
fix_redudant_initialization_parse_utilcmd.patch application/octet-stream 851 bytes
fix_redudant_initialization_procarray.patch application/octet-stream 742 bytes
fix_redudant_initialization_status_nbtsearch.patch application/octet-stream 1.1 KB
fix_redudant_initialization_storage.patch application/octet-stream 537 bytes
fix_redudant_initialization_spell.patch application/octet-stream 604 bytes
fix_redudant_initialization_syslogger.patch application/octet-stream 531 bytes
fix_redudant_initialization_to_tsany.patch application/octet-stream 878 bytes
fix_redudant_initialization_tsrank.patch application/octet-stream 452 bytes
fix_redudant_initialization_tuplesort.patch application/octet-stream 1.3 KB
fix_redudant_initialization_wparser_def.patch application/octet-stream 428 bytes
fix_redudant_prefix_spgtextproc.patch application/octet-stream 797 bytes
fix_redudant_waits_xlog.patch application/octet-stream 834 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Juan José Santamaría Flecha 2020-09-05 17:22:23 Re: A micro-optimisation for walkdir()
Previous Message Tom Lane 2020-09-05 15:27:49 Re: Fix for configure error in 9.5/9.6 on macOS 11.0 Big Sur