Re: Warning in the RecordTransactionAbort routine during compilation with O3 flag
Michael Paquier <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.bugs |
|---|---|
| Message-ID | <[email protected]> |
On Mon, Dec 09, 2019 at 02:03:43PM +0500, Andrey Lepikhov wrote: > We already have assertion on the twophase_gid variable. But compiler is not > so smart and can't find a link between the XACT_XINFO_HAS_GID flag and > state of twophase_gid pointer. Well, gcc-9 got visibly smarter on that point :) > Ok. In accordance with your review, I have prepared a new version of the > patch. Regarding formatting.c, I can see the point of avoiding future mistakes, and I would go a bit further as per the attached for consistency between all variables. have_error is a bit trickier though as it gets moved around more layers so doing an initialization in the middle is not really an option. Anyway, we can do that rather cleanly from the entry point of do_to_timestamp() to bring more consistency for variables which are always expected and the optional ones. What do you think? For the second one in xact.c, I am not really on board of doing something based on the proposals because this reduces the code visibility, and gcc is clearly wrong in its assumptions because the state cannot be reached. > My compiler: > > gcc -v > [...] > gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1) Thanks, that's the difference. gcc-9 does not complain, but I can see the warnings with gcc-7 (7.5.0 actually). -- xMichael
tmsp-formatting-warnings.patch
(text/x-diff, 867 B)
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index f7175df8da..8fcbc2267f 100644
--- a/src/backend/utils/adt/formatting.c
+++ b/src/backend/utils/adt/formatting.c
@@ -4128,7 +4128,7 @@ parse_datetime(text *date_txt, text *fmt, bool strict, Oid *typid,
{
struct pg_tm tm;
fsec_t fsec;
- int fprec = 0;
+ int fprec;
uint32 flags;
do_to_timestamp(date_txt, fmt, strict, &tm, &fsec, &fprec, &flags, have_error);
@@ -4318,11 +4318,18 @@ do_to_timestamp(text *date_txt, text *fmt, bool std,
int fmask;
bool incache = false;
+ Assert(tm != NULL);
+ Assert(fsec != NULL);
+
date_str = text_to_cstring(date_txt);
ZERO_tmfc(&tmfc);
ZERO_tm(tm);
*fsec = 0;
+ if (fprec)
+ *fprec = 0;
+ if (flags)
+ *flags = 0;
fmask = 0; /* bit mask for ValidateDate() */
fmt_len = VARSIZE_ANY_EXHDR(fmt);
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl3vDVgACgkQnvQgOdby QH39nA//dMFgDFG6G/e5DBoooAOJu8n3J/vS93AgOtlEPJweKtA61KrWhCw8kMR3 Vfhao0pKHE7d/sVHmReomXKR2U5HnVTXRN6eFzBmD7KptJoO46+Nf+wd9gGDtL7b fhgZY+vO7mlca5ccZZaDHpW0tbJ7IBPrbGenhxqTL6kt40lB47tq1ljNQoB/fyFn nuLFAnac3lLp7qabicNYMBRClTMqsBYwQJmR3L8Gmkh6fem9fWbz/wt2r8qcUzSL mGu2a79JH7g9z6MzhBfmYLiMlo7vE7SsOnkraUSvidWwHg4kbp0DghnSPboODVzD VkIbFfSEpLPTj1JzTMh9nL/kxyKRR0HzkSSucWqf1GsusJexUiyPSuIFvVdZUHzs d8tAb3kboN4YoYNDL0VliIf6ea6McxCewhz0LrEXVBwl3KE4XcgaBDcmQlrCYNYZ zPJbJ12wkh4dl42tAnPi/JIlSrVofZ3JqTi3gLyjbiuxb/grnGfrcWPp9kAgQwvS b7PTxkGVPoREtd5sgeE+gjOIOrQ4r61g5UUzNGMOaExK0sOlOtxm38PvdRDBmI4Z LeNbANzJXjm1oq7p0rOK6AOTTnUWwlooNfA50yhpNMDdgSh1q9UFMXNAAmp4h1R9 JIvXaspR3s8kEr/xVcUDWemX0oPrU6mSDV+gCRW9J4/Y8jAIHlw= =PZfq -----END PGP SIGNATURE-----