Warning in the RecordTransactionAbort routine during compilation with O3 flag
Andrey Lepikhov <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.bugs |
|---|---|
| Organization | Postgres Professional |
| Message-ID | <[email protected]> |
Compiling of master postgres branch with CFLAGS="-O3" shows compiler
warnings:
xact.c: In function ‘RecordTransactionAbort’:
xact.c:5709:55: warning: argument 1 null where non-null expected [-Wnonnull]
XLogRegisterData(unconstify(char *, twophase_gid),
strlen(twophase_gid) + 1);
^~~~~~~~~~~~~~~~~~~~
In file included from ../../../../src/include/c.h:61:0,
from ../../../../src/include/postgres.h:46,
from xact.c:18:
/usr/include/string.h:384:15: note: in a call to function ‘strlen’
declared here
extern size_t strlen (const char *__s)
^~~~~~
formatting.c: In function ‘parse_datetime’:
formatting.c:4229:13: warning: ‘flags’ may be used uninitialized in this
function [-Wmaybe-uninitialized]
if (flags & DCH_ZONED)
It's not a bug. But I prepare the patch to make compiler quiet.
--
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company
0001-Make-compiler-quiet.patch
(text/x-patch, 2.6 KB)
From 4c35a8f1f95557b2bf7fe3e50bf0fc6302d97e82 Mon Sep 17 00:00:00 2001 From: "Andrey V. Lepikhov" <[email protected]> Date: Mon, 9 Dec 2019 08:22:04 +0500 Subject: [PATCH] Make compiler quiet --- src/backend/access/transam/xact.c | 17 +++++++++-------- src/backend/utils/adt/formatting.c | 2 +- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 5353b6ab0b..46ed788ec4 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -5522,9 +5522,6 @@ XactLogCommitRecord(TimestampTz commit_time, xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE; xl_twophase.xid = twophase_xid; Assert(twophase_gid != NULL); - - if (XLogLogicalInfoActive()) - xl_xinfo.xinfo |= XACT_XINFO_HAS_GID; } /* dump transaction origin information */ @@ -5577,8 +5574,12 @@ XactLogCommitRecord(TimestampTz commit_time, if (xl_xinfo.xinfo & XACT_XINFO_HAS_TWOPHASE) { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); - if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) + + if (twophase_gid != NULL && XLogLogicalInfoActive()) + { + xl_xinfo.xinfo |= XACT_XINFO_HAS_GID; XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); + } } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) @@ -5648,9 +5649,6 @@ XactLogAbortRecord(TimestampTz abort_time, xl_xinfo.xinfo |= XACT_XINFO_HAS_TWOPHASE; xl_twophase.xid = twophase_xid; Assert(twophase_gid != NULL); - - if (XLogLogicalInfoActive()) - xl_xinfo.xinfo |= XACT_XINFO_HAS_GID; } if (TransactionIdIsValid(twophase_xid) && XLogLogicalInfoActive()) @@ -5705,8 +5703,11 @@ XactLogAbortRecord(TimestampTz abort_time, if (xl_xinfo.xinfo & XACT_XINFO_HAS_TWOPHASE) { XLogRegisterData((char *) (&xl_twophase), sizeof(xl_xact_twophase)); - if (xl_xinfo.xinfo & XACT_XINFO_HAS_GID) + if (twophase_gid != NULL && XLogLogicalInfoActive()) + { + xl_xinfo.xinfo |= XACT_XINFO_HAS_GID; XLogRegisterData(unconstify(char *, twophase_gid), strlen(twophase_gid) + 1); + } } if (xl_xinfo.xinfo & XACT_XINFO_HAS_ORIGIN) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index f7175df8da..9a3ef8baec 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -4129,7 +4129,7 @@ parse_datetime(text *date_txt, text *fmt, bool strict, Oid *typid, struct pg_tm tm; fsec_t fsec; int fprec = 0; - uint32 flags; + uint32 flags = 0; do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error); CHECK_ERROR; -- 2.17.1