Re: pread, pwrite, etc return ssize_t not int
Peter Eisentraut <peter@eisentraut.org>
From: Peter Eisentraut <peter@eisentraut.org>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@lists.postgresql.org
Date: 2024-03-02T05:16:04Z
Lists: pgsql-hackers
On 01.03.24 22:23, Thomas Munro wrote: >> For the overflow of the input length (size_t -> DWORD), I don't think we >> actually need to do anything. The size argument would be truncated, but >> the callers would just repeat the calls with the remaining size, so in >> effect they will read the data in chunks of rest + N * DWORD_MAX. The >> patch just changes this to chunks of N * 1GB + rest. > > But implicit conversion size_t -> DWORD doesn't convert large numbers > to DWORD_MAX, it just cuts off the high bits, and that might leave you > with zero. Zero has a special meaning (if we assume that kernel > doesn't reject a zero size argument outright, I dunno): if returned by > reads it indicates EOF, and if returned by writes a typical caller > would either loop forever making no progress or (in some of our code) > conjure up a fake ENOSPC. Hence desire to impose a cap. Right, my thinko. Your patch is correct then.
Commits
-
Fix overflow in Windows replacement pg_pread/pg_pwrite.
- 1e013746544b 17.0 landed
-
Return ssize_t in fd.c I/O functions.
- 653b55b57081 17.0 landed
-
Fix incorrect data type choices in some read and write calls.
- 98c6231d198a 17.0 landed
-
Update types in File API
- 2d4f1ba6cfc2 16.0 cited