Skip to content

Commit d914eb3

Browse files
committed
Remove workarounds for avoiding [U]INT64_FORMAT in translatable strings.
Update pg_backup_tar.c along the same lines as 62aa2bb and other previous cleanup: we can now rely on %lld or %llu as long as we explicitly cast to long long or unsigned long long. Japin Li Discussion: https://postgr.es/m/MEYP282MB16694F7CC1B119B4ECDD8CBEB6139@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
1 parent 3f1ce97 commit d914eb3

File tree

1 file changed

+9
-39
lines changed

1 file changed

+9
-39
lines changed

src/bin/pg_dump/pg_backup_tar.c

+9-39
Original file line numberDiff line numberDiff line change
@@ -1102,15 +1102,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
11021102
fatal("could not close temporary file: %m");
11031103

11041104
if (len != th->fileLen)
1105-
{
1106-
char buf1[32],
1107-
buf2[32];
1108-
1109-
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
1110-
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->fileLen);
1111-
fatal("actual file length (%s) does not match expected (%s)",
1112-
buf1, buf2);
1113-
}
1105+
fatal("actual file length (%lld) does not match expected (%lld)",
1106+
(long long) len, (long long) th->fileLen);
11141107

11151108
pad = tarPaddingBytesRequired(len);
11161109
for (i = 0; i < pad; i++)
@@ -1140,24 +1133,14 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
11401133
/* Go to end of current file, if any */
11411134
if (ctx->tarFHpos != 0)
11421135
{
1143-
char buf1[100],
1144-
buf2[100];
1145-
1146-
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ctx->tarFHpos);
1147-
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ctx->tarNextMember);
1148-
pg_log_debug("moving from position %s to next member at file position %s",
1149-
buf1, buf2);
1136+
pg_log_debug("moving from position %lld to next member at file position %lld",
1137+
(long long) ctx->tarFHpos, (long long) ctx->tarNextMember);
11501138

11511139
while (ctx->tarFHpos < ctx->tarNextMember)
11521140
_tarReadRaw(AH, &c, 1, NULL, ctx->tarFH);
11531141
}
11541142

1155-
{
1156-
char buf[100];
1157-
1158-
snprintf(buf, sizeof(buf), INT64_FORMAT, (int64) ctx->tarFHpos);
1159-
pg_log_debug("now at file position %s", buf);
1160-
}
1143+
pg_log_debug("now at file position %lld", (long long) ctx->tarFHpos);
11611144

11621145
/* We are at the start of the file, or at the next member */
11631146

@@ -1265,25 +1248,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
12651248

12661249
len = read_tar_number(&h[124], 12);
12671250

1268-
{
1269-
char posbuf[32];
1270-
char lenbuf[32];
1271-
1272-
snprintf(posbuf, sizeof(posbuf), UINT64_FORMAT, (uint64) hPos);
1273-
snprintf(lenbuf, sizeof(lenbuf), UINT64_FORMAT, (uint64) len);
1274-
pg_log_debug("TOC Entry %s at %s (length %s, checksum %d)",
1275-
tag, posbuf, lenbuf, sum);
1276-
}
1251+
pg_log_debug("TOC Entry %s at %llu (length %llu, checksum %d)",
1252+
tag, (unsigned long long) hPos, (unsigned long long) len, sum);
12771253

12781254
if (chk != sum)
1279-
{
1280-
char posbuf[32];
1281-
1282-
snprintf(posbuf, sizeof(posbuf), UINT64_FORMAT,
1283-
(uint64) ftello(ctx->tarFH));
1284-
fatal("corrupt tar header found in %s (expected %d, computed %d) file position %s",
1285-
tag, sum, chk, posbuf);
1286-
}
1255+
fatal("corrupt tar header found in %s (expected %d, computed %d) file position %llu",
1256+
tag, sum, chk, (unsigned long long) ftello(ctx->tarFH));
12871257

12881258
th->targetFile = pg_strdup(tag);
12891259
th->fileLen = len;

0 commit comments

Comments
 (0)