diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2020-06-24 15:47:30 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2020-06-24 15:47:54 -0400 |
commit | ff28f35d2ffb3a485c45d99039a1f17c3bd2a475 (patch) | |
tree | c759152fb62c463c978fb7203f261e3b96f09323 /src | |
parent | 013d324d51ef55cbfff50d4302261b5199cd3198 (diff) | |
download | postgresql-ff28f35d2ffb3a485c45d99039a1f17c3bd2a475.tar.gz postgresql-ff28f35d2ffb3a485c45d99039a1f17c3bd2a475.zip |
Fix compiler warning induced by commit d8b15eeb8.
I forgot that INT64_FORMAT can't be used with sscanf on Windows.
Use the same trick of sscanf'ing into a temp variable as we do in
some other places in zic.c.
The upstream IANA code avoids the portability problem by relying on
<inttypes.h>'s SCNdFAST64 macro. Once we're requiring C99 in all
branches, we should do likewise and drop this set of diffs from
upstream. For now, though, a hack seems fine, since we do not
actually care about leapseconds anyway.
Discussion: https://postgr.es/m/4e5d1a5b-143e-e70e-a99d-a3b01c1ae7c3@2ndquadrant.com
Diffstat (limited to 'src')
-rw-r--r-- | src/timezone/zic.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/timezone/zic.c b/src/timezone/zic.c index e5a3ca26f42..10c5b4bfb5b 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -1292,7 +1292,20 @@ infile(const char *name) if (nfields == 0) { if (name == leapsec && *buf == '#') - sscanf(buf, "#expires " INT64_FORMAT, &comment_leapexpires); + { + /* + * PG: INT64_FORMAT isn't portable for sscanf, so be content + * with scanning a "long". Once we are requiring C99 in all + * live branches, it'd be sensible to adopt upstream's + * practice of using the <inttypes.h> macros. But for now, we + * don't actually use this code, and it won't overflow before + * 2038 anyway. + */ + long cl_tmp; + + sscanf(buf, "#expires %ld", &cl_tmp); + comment_leapexpires = cl_tmp; + } } else if (wantcont) { |