Re: Return value of PathNameOpenFile() - Mailing list pgsql-hackers

From Daniel Gustafsson
Subject Re: Return value of PathNameOpenFile()
Date
Msg-id 1ECFEFA0-C3F7-450E-9571-EB22202F5B2D@yesql.se
Whole thread Raw
In response to Return value of PathNameOpenFile()  (Antonin Houska <ah@cybertec.at>)
Responses Re: Return value of PathNameOpenFile()
List pgsql-hackers
> On 6 Sep 2022, at 09:26, Antonin Houska <ah@cybertec.at> wrote:
>
> I've noticed that some callers of PathNameOpenFile()
> (e.g. bbsink_server_begin_archive()) consider the call failed even if the
> function returned zero, while other ones do check whether the file descriptor
> is strictly negative. Since the file descriptor is actually returned by the
> open() system call, I assume that zero is a valid result, isn't it?

Agreed, zero should be valid as it's a non-negative integer.  However, callers
in fd.c are themselves checking for (fd <= 0) in some cases, and some have done
so since the very early days of the codebase, so I wonder if there historically
used to be a platform which considered 0 an invalid fd?

--
Daniel Gustafsson        https://vmware.com/




pgsql-hackers by date:

Previous
From: Zhang Mingli
Date:
Subject: Re: Remove dead macro exec_subplan_get_plan
Next
From: "houzj.fnst@fujitsu.com"
Date:
Subject: RE: pg_publication_tables show dropped columns