Skip to content

Commit e03b807

Browse files
committed
Fix incorrect format placeholders
Also remove obsolete comments about why the 64-bit integers need to be printed in a separate buffer. The reason used to be portability, but now the remaining reason is that we need the string lengths for the progress displays. That is evident by looking at the code right below, so a new comment doesn't seem necessary.
1 parent f7e56f1 commit e03b807

File tree

3 files changed

+8
-23
lines changed

3 files changed

+8
-23
lines changed

src/bin/pg_amcheck/pg_amcheck.c

+4-9
Original file line numberDiff line numberDiff line change
@@ -1226,15 +1226,10 @@ progress_report(uint64 relations_total, uint64 relations_checked,
12261226
if (relpages_total)
12271227
percent_pages = (int) (relpages_checked * 100 / relpages_total);
12281228

1229-
/*
1230-
* Separate step to keep platform-dependent format code out of fprintf
1231-
* calls. We only test for INT64_FORMAT availability in snprintf, not
1232-
* fprintf.
1233-
*/
1234-
snprintf(checked_rel, sizeof(checked_rel), INT64_FORMAT, relations_checked);
1235-
snprintf(total_rel, sizeof(total_rel), INT64_FORMAT, relations_total);
1236-
snprintf(checked_pages, sizeof(checked_pages), INT64_FORMAT, relpages_checked);
1237-
snprintf(total_pages, sizeof(total_pages), INT64_FORMAT, relpages_total);
1229+
snprintf(checked_rel, sizeof(checked_rel), UINT64_FORMAT, relations_checked);
1230+
snprintf(total_rel, sizeof(total_rel), UINT64_FORMAT, relations_total);
1231+
snprintf(checked_pages, sizeof(checked_pages), UINT64_FORMAT, relpages_checked);
1232+
snprintf(total_pages, sizeof(total_pages), UINT64_FORMAT, relpages_total);
12381233

12391234
#define VERBOSE_DATNAME_LENGTH 35
12401235
if (opts.verbose)

src/bin/pg_basebackup/pg_basebackup.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -804,14 +804,9 @@ progress_report(int tablespacenum, const char *filename,
804804
if (totaldone / 1024 > totalsize_kb)
805805
totalsize_kb = totaldone / 1024;
806806

807-
/*
808-
* Separate step to keep platform-dependent format code out of
809-
* translatable strings. And we only test for INT64_FORMAT availability
810-
* in snprintf, not fprintf.
811-
*/
812-
snprintf(totaldone_str, sizeof(totaldone_str), INT64_FORMAT,
807+
snprintf(totaldone_str, sizeof(totaldone_str), UINT64_FORMAT,
813808
totaldone / 1024);
814-
snprintf(totalsize_str, sizeof(totalsize_str), INT64_FORMAT, totalsize_kb);
809+
snprintf(totalsize_str, sizeof(totalsize_str), UINT64_FORMAT, totalsize_kb);
815810

816811
#define VERBOSE_FILENAME_LENGTH 35
817812
if (verbose)

src/bin/pg_rewind/pg_rewind.c

+2-7
Original file line numberDiff line numberDiff line change
@@ -759,14 +759,9 @@ progress_report(bool finished)
759759
if (fetch_done > fetch_size)
760760
fetch_size = fetch_done;
761761

762-
/*
763-
* Separate step to keep platform-dependent format code out of
764-
* translatable strings. And we only test for INT64_FORMAT availability
765-
* in snprintf, not fprintf.
766-
*/
767-
snprintf(fetch_done_str, sizeof(fetch_done_str), INT64_FORMAT,
762+
snprintf(fetch_done_str, sizeof(fetch_done_str), UINT64_FORMAT,
768763
fetch_done / 1024);
769-
snprintf(fetch_size_str, sizeof(fetch_size_str), INT64_FORMAT,
764+
snprintf(fetch_size_str, sizeof(fetch_size_str), UINT64_FORMAT,
770765
fetch_size / 1024);
771766

772767
fprintf(stderr, _("%*s/%s kB (%d%%) copied"),

0 commit comments

Comments
 (0)