Zero initialize uses of instr_time about to trigger compiler warnings
authorAndres Freund <andres@anarazel.de>
Sat, 21 Jan 2023 05:16:47 +0000 (21:16 -0800)
committerAndres Freund <andres@anarazel.de>
Sat, 21 Jan 2023 05:16:47 +0000 (21:16 -0800)
These are all not necessary from a correctness POV. However, in the near
future instr_time will be simplified to an int64, at which point gcc would
otherwise start to warn about the changed places.

Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20230116023639.rn36vf6ajqmfciua@awork3.anarazel.de

src/backend/access/transam/xlog.c
src/backend/storage/buffer/bufmgr.c
src/backend/storage/file/buffile.c
src/backend/storage/ipc/latch.c
src/bin/psql/common.c

index cc0d9a05d9fd886029fd3e8223761418bb91a680..fb4c860bdea035715a2ce2c69007533b951fa307 100644 (file)
@@ -2191,6 +2191,8 @@ XLogWrite(XLogwrtRqst WriteRqst, TimeLineID tli, bool flexible)
                /* Measure I/O timing to write WAL data */
                if (track_wal_io_timing)
                    INSTR_TIME_SET_CURRENT(start);
+               else
+                   INSTR_TIME_SET_ZERO(start);
 
                pgstat_report_wait_start(WAIT_EVENT_WAL_WRITE);
                written = pg_pwrite(openLogFile, from, nleft, startoffset);
@@ -8151,6 +8153,8 @@ issue_xlog_fsync(int fd, XLogSegNo segno, TimeLineID tli)
    /* Measure I/O timing to sync the WAL file */
    if (track_wal_io_timing)
        INSTR_TIME_SET_CURRENT(start);
+   else
+       INSTR_TIME_SET_ZERO(start);
 
    pgstat_report_wait_start(WAIT_EVENT_WAL_SYNC);
    switch (sync_method)
index 8075828e8a68d0a45053c94a459152ae977a96f0..800a4248c955b7a7c1d895cba416a0f5888b992e 100644 (file)
@@ -1017,6 +1017,8 @@ ReadBuffer_common(SMgrRelation smgr, char relpersistence, ForkNumber forkNum,
 
            if (track_io_timing)
                INSTR_TIME_SET_CURRENT(io_start);
+           else
+               INSTR_TIME_SET_ZERO(io_start);
 
            smgrread(smgr, forkNum, blockNum, (char *) bufBlock);
 
@@ -2902,6 +2904,8 @@ FlushBuffer(BufferDesc *buf, SMgrRelation reln)
 
    if (track_io_timing)
        INSTR_TIME_SET_CURRENT(io_start);
+   else
+       INSTR_TIME_SET_ZERO(io_start);
 
    /*
     * bufToWrite is either the shared buffer or a copy, as appropriate.
index c5464b6aa628770c4f9f429380731b13c42bda4e..0a51624df3b31ba5614716210846b82b9b9adfe0 100644 (file)
@@ -446,6 +446,8 @@ BufFileLoadBuffer(BufFile *file)
 
    if (track_io_timing)
        INSTR_TIME_SET_CURRENT(io_start);
+   else
+       INSTR_TIME_SET_ZERO(io_start);
 
    /*
     * Read whatever we can get, up to a full bufferload.
@@ -525,6 +527,8 @@ BufFileDumpBuffer(BufFile *file)
 
        if (track_io_timing)
            INSTR_TIME_SET_CURRENT(io_start);
+       else
+           INSTR_TIME_SET_ZERO(io_start);
 
        bytestowrite = FileWrite(thisfile,
                                 file->buffer.data + wpos,
index d79d71a8515b020f9d50c8e5eac8167ba8211b3d..f4123e7de7e28a05b92229869d5ab35129342c4e 100644 (file)
@@ -1401,6 +1401,8 @@ WaitEventSetWait(WaitEventSet *set, long timeout,
        Assert(timeout >= 0 && timeout <= INT_MAX);
        cur_timeout = timeout;
    }
+   else
+       INSTR_TIME_SET_ZERO(start_time);
 
    pgstat_report_wait_start(wait_event_info);
 
index 00627830c47484c9764d1ed79cde4a6d53086e77..f907f5d4e8da80993a0fb47339613c3328a5696e 100644 (file)
@@ -1276,6 +1276,8 @@ DescribeQuery(const char *query, double *elapsed_msec)
 
    if (timing)
        INSTR_TIME_SET_CURRENT(before);
+   else
+       INSTR_TIME_SET_ZERO(before);
 
    /*
     * To parse the query but not execute it, we prepare it, using the unnamed
@@ -1406,6 +1408,8 @@ ExecQueryAndProcessResults(const char *query,
 
    if (timing)
        INSTR_TIME_SET_CURRENT(before);
+   else
+       INSTR_TIME_SET_ZERO(before);
 
    if (pset.bind_flag)
        success = PQsendQueryParams(pset.db, query, pset.bind_nparams, NULL, (const char * const *) pset.bind_params, NULL, NULL, 0);
@@ -1702,6 +1706,8 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
 
    if (timing)
        INSTR_TIME_SET_CURRENT(before);
+   else
+       INSTR_TIME_SET_ZERO(before);
 
    /* if we're not in a transaction, start one */
    if (PQtransactionStatus(pset.db) == PQTRANS_IDLE)