git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8729fa7)
Fix some compiler warnings with timestamp parsing in formatting.c
2019年12月11日 01:01:06 +0000 (10:01 +0900)
2019年12月11日 01:01:06 +0000 (10:01 +0900)
gcc-7 used with a sufficient optimization level complains about warnings
around do_to_timestamp() regarding the initialization and handling of
some of its variables. Recent commits 66c74f8 and d589f94 made things
made the interface more confusing, so document which variables are
always expected and initialize properly the optional ones when they are
set.

Author: Andrey Lepikhov, Michael Paquier
Discussion: https://postgr.es/m/a7e28b83-27b1-4e1c-c76b-4268c4b785bc@postgrespro.ru


diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c
index f7175df8da6ac502215c7acd651cf48a8f31e384..8fcbc2267f962a62615947a43561b0d51f8f2360 100644 (file)
--- 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);
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /