Remove workarounds for avoiding [U]INT64_FORMAT in translatable strings.

Update pg_backup_tar.c along the same lines as 62aa2bb29 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
This commit is contained in:
Tom Lane 2022-03-18 13:10:04 -04:00
parent 3f1ce97346
commit d914eb347f
1 changed files with 9 additions and 39 deletions

View File

@ -1102,15 +1102,8 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
fatal("could not close temporary file: %m"); fatal("could not close temporary file: %m");
if (len != th->fileLen) if (len != th->fileLen)
{ fatal("actual file length (%lld) does not match expected (%lld)",
char buf1[32], (long long) len, (long long) th->fileLen);
buf2[32];
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) len);
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) th->fileLen);
fatal("actual file length (%s) does not match expected (%s)",
buf1, buf2);
}
pad = tarPaddingBytesRequired(len); pad = tarPaddingBytesRequired(len);
for (i = 0; i < pad; i++) for (i = 0; i < pad; i++)
@ -1140,24 +1133,14 @@ _tarPositionTo(ArchiveHandle *AH, const char *filename)
/* Go to end of current file, if any */ /* Go to end of current file, if any */
if (ctx->tarFHpos != 0) if (ctx->tarFHpos != 0)
{ {
char buf1[100], pg_log_debug("moving from position %lld to next member at file position %lld",
buf2[100]; (long long) ctx->tarFHpos, (long long) ctx->tarNextMember);
snprintf(buf1, sizeof(buf1), INT64_FORMAT, (int64) ctx->tarFHpos);
snprintf(buf2, sizeof(buf2), INT64_FORMAT, (int64) ctx->tarNextMember);
pg_log_debug("moving from position %s to next member at file position %s",
buf1, buf2);
while (ctx->tarFHpos < ctx->tarNextMember) while (ctx->tarFHpos < ctx->tarNextMember)
_tarReadRaw(AH, &c, 1, NULL, ctx->tarFH); _tarReadRaw(AH, &c, 1, NULL, ctx->tarFH);
} }
{ pg_log_debug("now at file position %lld", (long long) ctx->tarFHpos);
char buf[100];
snprintf(buf, sizeof(buf), INT64_FORMAT, (int64) ctx->tarFHpos);
pg_log_debug("now at file position %s", buf);
}
/* We are at the start of the file, or at the next member */ /* We are at the start of the file, or at the next member */
@ -1265,25 +1248,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
len = read_tar_number(&h[124], 12); len = read_tar_number(&h[124], 12);
{ pg_log_debug("TOC Entry %s at %llu (length %llu, checksum %d)",
char posbuf[32]; tag, (unsigned long long) hPos, (unsigned long long) len, sum);
char lenbuf[32];
snprintf(posbuf, sizeof(posbuf), UINT64_FORMAT, (uint64) hPos);
snprintf(lenbuf, sizeof(lenbuf), UINT64_FORMAT, (uint64) len);
pg_log_debug("TOC Entry %s at %s (length %s, checksum %d)",
tag, posbuf, lenbuf, sum);
}
if (chk != sum) if (chk != sum)
{ fatal("corrupt tar header found in %s (expected %d, computed %d) file position %llu",
char posbuf[32]; tag, sum, chk, (unsigned long long) ftello(ctx->tarFH));
snprintf(posbuf, sizeof(posbuf), UINT64_FORMAT,
(uint64) ftello(ctx->tarFH));
fatal("corrupt tar header found in %s (expected %d, computed %d) file position %s",
tag, sum, chk, posbuf);
}
th->targetFile = pg_strdup(tag); th->targetFile = pg_strdup(tag);
th->fileLen = len; th->fileLen = len;