Re: pg_logging_init() can return ENOTTY with TAP tests - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_logging_init() can return ENOTTY with TAP tests
Date
Msg-id 445428.1600437374@sss.pgh.pa.us
Whole thread Raw
In response to pg_logging_init() can return ENOTTY with TAP tests  (Michael Paquier <michael@paquier.xyz>)
Responses Re: pg_logging_init() can return ENOTTY with TAP tests  (Michael Paquier <michael@paquier.xyz>)
List pgsql-hackers
Michael Paquier <michael@paquier.xyz> writes:
> Some system calls may not set errno even if they succeed, like
> strtol() on Linux for example, so in this case it can cause option
> handling to fail because of the error set by logging initialization.
> Shouldn't we reset errno to 0 once logging initialization is done?  It
> seems to me that this code path should finish with a clean sheet, and
> attached is a proposal of patch to address this issue.

No, this is a bad idea.  The right place to fix this is whatever code
segment is relying on errno to be initially zero; that is NEVER a sane
assumption.  That is, a valid coding pattern is something like

         errno = 0;
         strtol(...);
         if (errno) ...

            regards, tom lane



pgsql-hackers by date:

Previous
From: Masahiko Sawada
Date:
Subject: Re: Transactions involving multiple postgres foreign servers, take 2
Next
From: Daniel Gustafsson
Date:
Subject: Re: OpenSSL 3.0.0 compatibility