Re: [HACKERS] make async slave to wait for lsn to be replayed - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: [HACKERS] make async slave to wait for lsn to be replayed
Date
Msg-id 29D84127-9F3D-4C4C-A585-C19E5849216A@yesql.se
Whole thread Raw
In response to Re: [HACKERS] make async slave to wait for lsn to be replayed  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Buildfarm animal mamba (NetBSD 10.0 on macppc) started failing on this with
what seems like a bogus compiler warning:

waitlsn.c: In function 'WaitForLSN':
waitlsn.c:275:24: error: 'endtime' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  275 |    delay_ms = (endtime - GetCurrentTimestamp()) / 1000;
      |               ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

endtime is indeed initialized further up, but initializing endtime at
declaration seems innocent enough and should make this compiler happy and the
buildfarm greener.

diff --git a/src/backend/commands/waitlsn.c b/src/backend/commands/waitlsn.c
index 6679378156..17ad0057ad 100644
--- a/src/backend/commands/waitlsn.c
+++ b/src/backend/commands/waitlsn.c
@@ -226,7 +226,7 @@ void
 WaitForLSN(XLogRecPtr targetLSN, int64 timeout)
 {
        XLogRecPtr      currentLSN;
-       TimestampTz endtime;
+       TimestampTz endtime = 0;

        /* Shouldn't be called when shmem isn't initialized */
        Assert(waitLSN);

--
Daniel Gustafsson




pgsql-hackers by date:

Previous
From: walther@technowledgy.de
Date:
Subject: Re: RFC: Additional Directory for Extensions
Next
From: Bertrand Drouvot
Date:
Subject: Re: Introduce XID age and inactive timeout based replication slot invalidation