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

Commit 15a79c7

Browse files
committed
Use PRI*64 instead of "ll*" in format strings (minimal trial)
Old: errmsg("hello %llu", (unsigned long long) x) New: errmsg("hello %" PRIu64, x) And likewise for everything printf-like. In the past we had to use long long so localized format strings remained architecture independent in message catalogs. Although long long is expected to be 64 bit everywhere, if we hadn't also cast the int64 values, we'd have generated compiler warnings on systems where int64 was long. Now that int64 is int64_t, C99 understand how to format them using <inttypes.h> macros, the casts are not necessary, and the gettext() tools recognize the macros and defer expansion until load time. (And if we ever manage to get -Wformat-signedness to work for us, that'd help with these too, but not the type-system-clobbering casts.) This particular patch converts only pg_checksums.c to the new system, to allow testing of the translation toolchain for everyone. If this works okay, a later patch will convert most of the rest. Author: Thomas Munro <thomas.munro@gmail.com> Discussion: https://postgr.es/m/b936d2fb-590d-49c3-a615-92c3a88c6c19%40eisentraut.org
1 parent 00d61a0 commit 15a79c7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/bin/pg_checksums/pg_checksums.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ progress_report(bool finished)
141141
/* Calculate current percentage of size done */
142142
percent = total_size ? (int) ((current_size) * 100 / total_size) : 0;
143143

144-
fprintf(stderr, _("%lld/%lld MB (%d%%) computed"),
145-
(long long) (current_size / (1024 * 1024)),
146-
(long long) (total_size / (1024 * 1024)),
144+
fprintf(stderr, _("%" PRId64 "/%" PRId64 " MB (%d%%) computed"),
145+
(current_size / (1024 * 1024)),
146+
(total_size / (1024 * 1024)),
147147
percent);
148148

149149
/*
@@ -603,20 +603,20 @@ main(int argc, char *argv[])
603603
progress_report(true);
604604

605605
printf(_("Checksum operation completed\n"));
606-
printf(_("Files scanned: %lld\n"), (long long) files_scanned);
607-
printf(_("Blocks scanned: %lld\n"), (long long) blocks_scanned);
606+
printf(_("Files scanned: %" PRId64 "\n"), files_scanned);
607+
printf(_("Blocks scanned: %" PRId64 "\n"), blocks_scanned);
608608
if (mode == PG_MODE_CHECK)
609609
{
610-
printf(_("Bad checksums: %lld\n"), (long long) badblocks);
610+
printf(_("Bad checksums: %" PRId64 "\n"), badblocks);
611611
printf(_("Data checksum version: %u\n"), ControlFile->data_checksum_version);
612612

613613
if (badblocks > 0)
614614
exit(1);
615615
}
616616
else if (mode == PG_MODE_ENABLE)
617617
{
618-
printf(_("Files written: %lld\n"), (long long) files_written);
619-
printf(_("Blocks written: %lld\n"), (long long) blocks_written);
618+
printf(_("Files written: %" PRId64 "\n"), files_written);
619+
printf(_("Blocks written: %" PRId64 "\n"), blocks_written);
620620
}
621621
}
622622

0 commit comments

Comments
 (0)