Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 235c0f6

Browse files
committed
Fix compiler warning induced by commit d8b15ee.
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
1 parent b8fd4e0 commit 235c0f6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/timezone/zic.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,20 @@ infile(const char *name)
12921292
if (nfields == 0)
12931293
{
12941294
if (name == leapsec && *buf == '#')
1295-
sscanf(buf, "#expires " INT64_FORMAT, &comment_leapexpires);
1295+
{
1296+
/*
1297+
* PG: INT64_FORMAT isn't portable for sscanf, so be content
1298+
* with scanning a "long". Once we are requiring C99 in all
1299+
* live branches, it'd be sensible to adopt upstream's
1300+
* practice of using the <inttypes.h> macros. But for now, we
1301+
* don't actually use this code, and it won't overflow before
1302+
* 2038 anyway.
1303+
*/
1304+
long cl_tmp;
1305+
1306+
sscanf(buf, "#expires %ld", &cl_tmp);
1307+
comment_leapexpires = cl_tmp;
1308+
}
12961309
}
12971310
else if (wantcont)
12981311
{

0 commit comments

Comments
 (0)