Fix error handling in pg_flush_data() and FilePrefetch()

posix_fadvise() returns an error code directly instead of setting
errno. However, pg_flush_data() uses %m and errcode_for_file_access()
to report errors without setting errno, potentially reporting an
unrelated error. Fix this by assigning the returned error code to
errno before reporting the error.

FilePrefetch() is documented to return an errno error code on failure,
but it returns -1 when FileAccess() fails. Fix this by returning errno
instead.

The first bug one only affects a warning, and the second doesn't have
any effect because the only existing caller ignores the return value.
So these are pretty harmless bugs, but let's be tidy.

Author: Chao Li <[email protected]>
Discussion: 
https://www.postgresql.org/message-id/[email protected]
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/61a372b795ddec08c15518096fe1f3e9e9973096

Modified Files
--------------
src/backend/storage/file/fd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

Reply via email to