Re: Possible uninitialized use of the variables (src/backend/access/transam/twophase.c) - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject Re: Possible uninitialized use of the variables (src/backend/access/transam/twophase.c)
Date
Msg-id 20220210.101815.265604321529150472.horikyota.ntt@gmail.com
Whole thread Raw
In response to Possible uninitialized use of the variables (src/backend/access/transam/twophase.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: Possible uninitialized use of the variables (src/backend/access/transam/twophase.c)  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
At Wed, 9 Feb 2022 08:15:45 -0300, Ranier Vilela <ranier.vf@gmail.com> wrote in 
> Hi,
> 
> Commit
> https://github.com/postgres/postgres/commit/1eb6d6527aae264b3e0b9c95aa70bb7a594ad1cf,
> modified
> data struct TwoPhaseFileHeader and added two new fields:
> 
> XLogRecPtr origin_lsn; /* lsn of this record at origin node */
> TimestampTz origin_timestamp; /* time of prepare at origin node */
> 
> I think thay forgot initialize these fields in the function StartPrepare
> because,
> when calling function save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
> 
> I have one report about possible uninitialized usage of the variables.

Who repoerted that to you?

StartPrepare and EndPrepare are virtually a single function that
accepts some additional operations in the middle.  StartPrepare leaves
the "records" incomplete then EndPrepare completes it.  It is not
designed so that the fields are accessed from others before the
completion.  There seems to be no critical reasons for EndPrepare to
do the pointed operations, but looking that another replorigin-related
operation is needed in the same function, it is sensible that the
author intended to consolidate all replorigin related changes in
EndPrepare.

So, my humble opinion here is, that change is not needed.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Justin Pryzby
Next
From: Peter Smith
Date:
Subject: Re: GetRelationPublicationActions. - Remove unreachable code