0002-Print-off_t-pgoff_t-consistently-as-lld.patch

text/plain

Filename: 0002-Print-off_t-pgoff_t-consistently-as-lld.patch
Type: text/plain
Part: 1
Message: truncating casts of pgoff_t

Patch

Format: format-patch
Series: patch 0002
Subject: Print off_t/pgoff_t consistently as %lld
File+
src/bin/pg_combinebackup/reconstruct.c 5 5
src/bin/pg_dump/pg_backup_tar.c 4 4
src/bin/pg_verifybackup/astreamer_verify.c 2 2
src/bin/pg_verifybackup/pg_verifybackup.c 3 3
From 51214bcaf25a3b647932ce93bdc0308e93543431 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Fri, 12 Jun 2026 10:12:08 +0200
Subject: [PATCH 2/2] Print off_t/pgoff_t consistently as %lld

This was the dominant style already, but some places used %llu
instead.  Since off_t/pgoff_t are signed types, using %lld seems a
better match, and it might handle obscure error conditions with
negative values better.
---
 src/bin/pg_combinebackup/reconstruct.c     | 10 +++++-----
 src/bin/pg_dump/pg_backup_tar.c            |  8 ++++----
 src/bin/pg_verifybackup/astreamer_verify.c |  4 ++--
 src/bin/pg_verifybackup/pg_verifybackup.c  |  6 +++---
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/src/bin/pg_combinebackup/reconstruct.c b/src/bin/pg_combinebackup/reconstruct.c
index 0541e6dacab..73b38236481 100644
--- a/src/bin/pg_combinebackup/reconstruct.c
+++ b/src/bin/pg_combinebackup/reconstruct.c
@@ -421,10 +421,10 @@ debug_reconstruction(int n_source, rfile **sources, bool dry_run)
 			if (fstat(s->fd, &sb) < 0)
 				pg_fatal("could not stat file \"%s\": %m", s->filename);
 			if (sb.st_size < s->highest_offset_read)
-				pg_fatal("file \"%s\" is too short: expected %llu, found %llu",
+				pg_fatal("file \"%s\" is too short: expected %lld, found %lld",
 						 s->filename,
-						 (unsigned long long) s->highest_offset_read,
-						 (unsigned long long) sb.st_size);
+						 (long long) s->highest_offset_read,
+						 (long long) sb.st_size);
 		}
 	}
 }
@@ -785,7 +785,7 @@ read_block(const rfile *s, off_t off, uint8 *buffer)
 		if (rb < 0)
 			pg_fatal("could not read from file \"%s\": %m", s->filename);
 		else
-			pg_fatal("could not read from file \"%s\", offset %llu: read %d of %d",
-					 s->filename, (unsigned long long) off, rb, BLCKSZ);
+			pg_fatal("could not read from file \"%s\", offset %lld: read %d of %d",
+					 s->filename, (long long) off, rb, BLCKSZ);
 	}
 }
diff --git a/src/bin/pg_dump/pg_backup_tar.c b/src/bin/pg_dump/pg_backup_tar.c
index 55b1e4e85d0..1f5d55d0365 100644
--- a/src/bin/pg_dump/pg_backup_tar.c
+++ b/src/bin/pg_dump/pg_backup_tar.c
@@ -1169,12 +1169,12 @@ _tarGetHeader(ArchiveHandle *AH, TAR_MEMBER *th)
 
 	len = read_tar_number(&h[TAR_OFFSET_SIZE], 12);
 
-	pg_log_debug("TOC Entry %s at %llu (length %llu, checksum %d)",
-				 tag, (unsigned long long) hPos, (unsigned long long) len, sum);
+	pg_log_debug("TOC Entry %s at %lld (length %lld, checksum %d)",
+				 tag, (long long) hPos, (long long) len, sum);
 
 	if (chk != sum)
-		pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %llu",
-				 tag, sum, chk, (unsigned long long) ftello(ctx->tarFH));
+		pg_fatal("corrupt tar header found in %s (expected %d, computed %d) file position %lld",
+				 tag, sum, chk, (long long) ftello(ctx->tarFH));
 
 	th->targetFile = pg_strdup(tag);
 	th->fileLen = len;
diff --git a/src/bin/pg_verifybackup/astreamer_verify.c b/src/bin/pg_verifybackup/astreamer_verify.c
index 99bd69ce7c9..2578765b0ca 100644
--- a/src/bin/pg_verifybackup/astreamer_verify.c
+++ b/src/bin/pg_verifybackup/astreamer_verify.c
@@ -208,9 +208,9 @@ member_verify_header(astreamer *streamer, astreamer_member *member)
 	if (m->size != member->size)
 	{
 		report_backup_error(mystreamer->context,
-							"file \"%s\" has size %llu in archive \"%s\" but size %" PRIu64 " in the manifest",
+							"file \"%s\" has size %lld in archive \"%s\" but size %" PRIu64 " in the manifest",
 							member->pathname,
-							(unsigned long long) member->size,
+							(long long) member->size,
 							mystreamer->archive_name,
 							m->size);
 		m->bad = true;
diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c
index bd4fe635c6f..5c63bea14c7 100644
--- a/src/bin/pg_verifybackup/pg_verifybackup.c
+++ b/src/bin/pg_verifybackup/pg_verifybackup.c
@@ -735,9 +735,9 @@ verify_plain_backup_file(verifier_context *context, char *relpath,
 	if (m->size != sb.st_size)
 	{
 		report_backup_error(context,
-							"\"%s\" has size %llu on disk but size %llu in the manifest",
-							relpath, (unsigned long long) sb.st_size,
-							(unsigned long long) m->size);
+							"\"%s\" has size %lld on disk but size %" PRIu64 " in the manifest",
+							relpath, (long long) sb.st_size,
+							m->size);
 		m->bad = true;
 	}
 
-- 
2.54.0