truncating casts of pgoff_t

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: truncating casts of pgoff_t
Date: 2026-06-22 07:56:55
Message-ID: 20ce62fa-47fc-457b-b504-12f3c1651726@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I found a couple of places where a pgoff_t value, typically a signed
64-bit integer, is cast to a type with a smaller range. I noticed this
specifically in error messages, so it's mostly cosmetic. Also, files
with a size where this would matter are not expected in many places, but
I suspect that the case in basebackup_server.c in the attached patch can
actually happen.

The fix is to use the %lld print format and a cast to long long int,
which is the style already in most places.

In passing, I also converted a few places that used %llu to print
pgoff_t to also use %lld instead. This is mostly for consistency, but
it also feels more robust in case a negative value ever sneaks in.

Attachment Content-Type Size
0001-Don-t-cast-pgoff_t-to-possibly-32-bit-types-for-outp.patch text/plain 3.7 KB
0002-Print-off_t-pgoff_t-consistently-as-lld.patch text/plain 4.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-06-22 08:10:22 Re: pgbench --continue-on-error: clarify TPS and failure reporting
Previous Message Kyotaro Horiguchi 2026-06-22 07:46:42 Re: doc: should pg_createsubscriber be grouped as a client application?