truncating casts of pgoff_t - Mailing list pgsql-hackers

From Peter Eisentraut
Subject truncating casts of pgoff_t
Date
Msg-id 20ce62fa-47fc-457b-b504-12f3c1651726@eisentraut.org
Whole thread
Responses Re: truncating casts of pgoff_t
List 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

pgsql-hackers by date:

Previous
From: Kyotaro Horiguchi
Date:
Subject: Re: doc: should pg_createsubscriber be grouped as a client application?
Next
From: Chao Li
Date:
Subject: Re: pgbench --continue-on-error: clarify TPS and failure reporting